From: Trans Date: 2005-04-16T03:14:37+09:00 Subject: Re: class locals as class methods Actually I should go further with this... The idea of a clean nomenclature is very appealing, which is one of the resons the idea of this thread is appealing to me. But I do see the point of the "scratch-pad" variable. What's interesting though, is that it is this distinction that really matters: whether the var is temporary or permanant. How do we mark that distinction now? Lo, it's not as far from what I had imagined as it is, actually. You can define just such a variable using an @ sign. Of course you still need to create the accessor methods to go with it: class X @a = 1 def self.a ; @a ; end def self.a=(x) ; @a = x ; end end But this is what gets me when I think about it. It is this form --the accessor form, that requires all this extra footwork; not the "scratch-pad" local vars. You'd think it were the local vars that were most commonly used then, but they aren't. So it would seem preferable to make the locals the ones with the extra syntax, either in defining them like a := 1 or a prefix, like %a = 1 or something. Yet, going further, we might take this down to the method level too. It has been suggested before (and I think quite reasonably) that we could have local methods: class X def a def b "1" end b end end In this case #b is local to #a. Applying the idea of this thread in this context would mean that local vars are local methods too. So, class X def a b = "1" b end end would be equivalent to the previous example. Here, again the "scratch-pad" critique posses an issue. In effect the local vars are becoming persistant. So, we could make a distinction between the persitant vs. non-persistant to deal with this, but in this case the syntax it is not quite as clear b/c local vars are much more common in this method context. T.