From: Just Another Victim of the Ambient Morality Date: 2006-08-01T10:15:09+09:00 Subject: Re: I thought this was the one that worked? "Chad Perrin" wrote in message news:20060731230559.GA27910@apotheon.com... > > Who said it's different? I'm just asking about the foregoing statement > that all blocks are closures (which strikes me as improbable). That's > like saying that this will generate a closure (which it won't): > > sub foo { > return sub { my $bar = 1; print ++$bar }; > } Okay, the mere fact that you "used a Perl example" demonstrates that there is a miscommunication going on here. Why would an example from Perl clear anything up? It's a different language with different semantics. Are you hoping that we all know Perl? I suspect what's happening here is that we're mixing up code blocks with "Ruby blocks." These are examples of what most programmers would call blocks but are _not_ Ruby blocks: def some_method_as_function # code block goes here but # in the Ruby world, this is not a "block..." end while some_condition # code block goes here but # in the Ruby world, this is not a "block..." end These are Ruby blocks: [1, 2, 3].each do |i| # this is a Ruby block and # this is a closure end some_local_variable = 2 func = lambda { puts some_local_variable } # a one line block and closure All things that are called "blocks" in Ruby are closures. Do you still have any questions on the matter?