From: "rits (First Last)" Date: 2013-08-05T13:16:50+09:00 Subject: [ruby-core:56381] [ruby-trunk - Feature #8693] lambda invoked by yield acts as a proc with respect to return Issue #8693 has been updated by rits (First Last). mame (Yusuke Endoh) wrote: > > A better reason is often required to change a spec and/or behavior. You and others keep referring to some "spec" without linking or quoting it. Since you seem to respect the idea of a spec, allow me to quote again the closest thing there is to a spec, matz' "the ruby programming language" book: "A return statement in a lambda, therefore, returns from the lambda itself, not from the method that surrounds the creation site of the lambda" "The fact that return in a lambda only returns from the lambda itself means that we never have to worry about LocalJumpError" yield is invoking a lambda, as already demonstrated, it is not a naked block somehow extracted and separated from the discarded lambda, the original lambda is still alive and still enforcing arity. Therefore lambda semantics should hold. Having yield invoke lambdas with consistent (as opposed to current schizophrenic behavior) block semantics, I would argue is still a violation of the spec and common sense. The definition of a lambda is its semantics, so they should not vary. ---------------------------------------- Feature #8693: lambda invoked by yield acts as a proc with respect to return https://bugs.ruby-lang.org/issues/8693#change-40895 Author: rits (First Last) Status: Assigned Priority: Normal Assignee: matz (Yukihiro Matsumoto) Category: Target version: irb(main):004:0> def m1; yield end; def m2; m1 &->{return 0}; 1 end; m2 => 0 -- http://bugs.ruby-lang.org/