From: Morton Goldberg Date: 2006-09-12T15:08:22+09:00 Subject: Re: Struggling with Blocks On Sep 11, 2006, at 9:39 PM, Rick DeNatale wrote: > I have to admit that I was struggling a bit when I made the analogy to > an anonymous method. The key is that begin pushes a new stack frame > onto the call stack. > > You are right about the scoping of local variables. The problem -- for me -- is that I can also make the analogy that 'begin ... end' is like 'lambda do ... end.call' with about the same degree of accuracy (or inaccuracy if you prefer). This second analogy would reflect the scoping rules better, but is a worse fit than your analogy when 'rescue', 'else', 'ensure', are added to the equation. If 'lambda do ... end' were to acquire the semantics of 'lambda do; begin ... end; end', then the analogy would be (almost?) exact and the OP less confused, but perhaps I'm begging the question more than clarifying anything. Also, such a change might introduce problems that haven't occurred to me. So I'm not proposing an RCR. Nonetheless, I have sympathy for the OP. The different semantics of 'begin ... end' and 'do ... end' _are_ confusing. Regards, Morton