From: Tom Sawyer Date: 2003-02-15T07:01:21+09:00 Subject: Re: Lexical scope and closures On Friday 14 February 2003 12:20 am, Tom Sawyer wrote: > On Thursday 13 February 2003 08:03 pm, Yukihiro Matsumoto wrote: > > arr.each {|i| > > let a = .. > > let b = .. > > c = .. > > ... > > } i'm concerned about using 'let' as it would not be clear why we wouldn't use it across the board. why would blocks be special? for example: > class A > def inititalize > c = "instead of @c" > let a = "instead of just a" > end > end so, i'd be more comfortable specifying locals as one does with private, public, etc.: arr.each { |i| local :a, :b a = .. b = .. ... } *** on another note: this matter has become tricky to deal with because of the way in which ruby deals with scoping instance variables, vs. instance methods, vs. local variables, etc. point blank: it is not symmetrical. i wish it could be made so, but that would of course break code. :-( just the same i'll put the idea out here: class A def initialize # local variables initialize.a ="instead of just a" %b = "as sugar for above (used in blocks)" # instance variables self.c = "instead of @c" d = "as above but where self is implied" # class variables A.e = "instead of @@e" @f = "this then could be class variable sugar" # globals toplevel.g = "or global.g" $h = "global sugar" end end -- tom sawyer, aka transami transami@transami.net