From: Nick Sabalausky Date: 2010-03-03T04:12:04+09:00 Subject: Re: Here's a filtered file/dir copy, FWIW. Ryan Davis wrote: > On Mar 1, 2010, at 16:32 , Nick Sabalausky wrote: > >> That "do |value|...end" is *not* a full function literal like I was >> expecting it to be, but some kind of...like a closure of a portion of >> the function it's contained in. More like using cross-function goto's >> than calling a passed-in function. > > That is exactly what a block is... a closure. > Soapbox on terminology: Though these terms *frequently* get mixed up, "closure" merely refers to the ability of code to access locals from the function it's defined within regardless of whether or not that enclosing function has returned (And yes, Ruby's closures fit this definition, or at least as far as I can tell). But, "closure" does *not* imply that it isn't a function - in fact, in most languages, closures *are* full-fledged functions that are, depending on the language, created with either nested functions and/or anonymous function literals. I've dealt with closures in plenty of different languages and this is still the first one I've come across where returning from a closure also returned from the function that invoked the closure and all the way down the stack through the function it was created within. So no, that's not how closures necessarily work. -- Posted via http://www.ruby-forum.com/.