From: Jacob Burkhart Date: 2007-05-31T21:32:28+09:00 Subject: Re: Introducing the "it" keyword consider the clarity of reading these: with(v+1) do |a| with(x+2) do |b| return a if a+b < 10 end end vs. with:a(v+1) do with:b(x+2) do return a if a+b < 10 end end with:var could be usefull in other scenrios as well, yes? We could say that with:a(v+1) is just an abbreviation for with( :a => v+1 ) and with is just a method that has the magical ability to bind variables in the scope of the block it's given. (so in this case bind 'a' with the value of 'v + 1') am I crazy? On 5/31/07, Jacob Burkhart wrote: > Would a let or with construct be fast enough and memory efficient > enough for those concerned about such things? > > def with(args*) > yield args > end > > with( v + 1 ) do |it| > return it if it < 10 > end > > If this isn't fast enough or memory-efficient enough, then I would > suggest we find a way to make the interpreter recognize or optimize > such cases. > > Perhaps "with" could be provided by the language by default, and then > we could support this line as syntactic sugar: > > return it if with(v+1) < 10 > > or maybe: > return it if with_it(v+1) < 10 > > The interpreter would have to recognize and transform this into the > equivalent with ... do ... end > > Or maybe we can go really crazy with the syntax, and support any name > for the 'tmp' variable (and any number of temp variables) with the > knowledge that if we use this syntax to assign them, the interpreter > will know to transform and garbage collect appropriately. > > return it if with:it(v+1) < 10 > > return a if with:a(v+1) < 10 > > return a,b if ( with:a(v+1) + with:b(x*y) ) < 10 >