Issue #15973 has been updated by Eregon (Benoit Daloze).


ko1 (Koichi Sasada) wrote:
> more aggressive proposal is obsolete `lambda` call, and use `->` (maybe it is too aggressive).

Sounds even better to me, but I guess that might be disruptive for everyone to adopt `-> {}` style.
It would be interesting to see what matz thinks about this.

`->` exists since at least 2.0, so it shouldn't be a compatibility issue to use it.

From the point of view of a Ruby VM, not having to handle `#lambda` magically changing the semantics of the passed block would be great,
because it's really awkward and hard to check if the block is literal or not (considering `lambda` can be `alias`-ed).

It would also simplify the semantics for the user: `method_call { ... }` is always a non-lambda Proc, and `-> {}` is the only way for a lambda.

----------------------------------------
Feature #15973: Let Kernel#lambda always return a lambda
https://bugs.ruby-lang.org/issues/15973#change-83392

* Author: alanwu (Alan Wu)
* Status: Assigned
* Priority: Normal
* Assignee: matz (Yukihiro Matsumoto)
* Target version: 2.8
----------------------------------------
When Kernel#lambda receives a Proc that is not a lambda,
it returns it without modification. l propose to change `Kernel#lambda`
so it always returns a lambda.

Calling a method called lambda and having it do nothing in effect is
not very intuitive.

https://github.com/ruby/ruby/pull/2262

Judging from marcandre's investigation here: https://bugs.ruby-lang.org/issues/15620#note-1,
changing the behavior should not cause much breakage, if any.


This also happens to fix [Bug #15620]



-- 
https://bugs.ruby-lang.org/

Unsubscribe: <mailto:ruby-core-request / ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>