From: Mark Hubbart Date: 2005-01-21T04:48:58+09:00 Subject: Re: Confused about variable "declarations" On Fri, 21 Jan 2005 02:31:00 +0900, Robert Klemme wrote: > > "Mark Hubbart" schrieb im Newsbeitrag > news:de63abca050120090877cc9971@mail.gmail.com... > > On Thu, 20 Jan 2005 21:01:01 +0900, Graham Nicholls > > wrote: > > > No worries, and thanks, but I think that the problem was that offset > is > > > being set inside an iterator (they still confuse me - any pointers to > a > > > good explanation would be nice!), which means that it is out of scope > > > outside the iterator. > > > > A short explanation: Blocks have a sort of "leaky scope", where > > variables from outside the scope can leak in and out, but those that > > are from the inside don't leak out. for example: > > While I completely agree with your explanation the word "leaky" strikes me > as odd as it seems to suggest uncommon or defective behavior: It wasn't meant to, though I now see why one might take it that way. I was using a picture from my mental image of block scope. Not everything that leaks is defective; some things are supposed to. I would consider a tightly sealed sieve or funnel to be defective :) > it's very > common in programming languages, that variables are visible in nested > scopes but not surrounding scopes: [...] I know, but in Ruby, blocks are the only exception to the rule, that I know of. Excepting blocks, all scopes are clearly defined, and you have to use tricks to access the variables in other scopes. But I'll concede the word "leaky". Perhaps there is a better term for it :) cheers, Mark