From: Christophe Grandsire Date: 2005-10-12T15:48:56+09:00 Subject: Re: Default argument values for blocks Selon Eric Mahurin : > > Would you consider having something like a begin/end block > having this ability too? > > b=1 > begin(b) > b=5 > p b # => 5 > end > p b # => 1 > Interesting. This syntax and the meaning of it remind me of METAFONT's way of declaring scope (I seem to be one of the few people on Earth besides Knuth who know a bit of METAFONT, and that's too bad because the language has some interesting features). In METAFONT (which is structured but not oo) scoping and subroutine definitions are completely separate. In other words you have to scope explicitly when you want a new scope. You do that through (surprisingly enough ;) ) a "begin... end;" block. In the block, all variables from the outside scope are known, so if you want to reuse the name of one of those locally you have to explicitly "save" it first. So in METAFONT your example would read: b=1; begin save b; b=5; message b % => 5 end; message b; % => 1 I must say I like the "save b" syntax. If begin/end blocks in Ruby are to have the same ability, it may be an idea (I personally find "begin(b)" unclear. It looks more to me like you're starting a block somehow indicated by a kind of label "b" or something like that ;) ). -- Christophe Grandsire. http://rainbow.conlang.free.fr It takes a straight mind to create a twisted conlang.