[ruby-core:96467] [Ruby master Feature#15973] Let Kernel#lambda always return a lambda

[email protected] Wed, 25 Dec 2019 11:20:12 +0000 (UTC)
Newsgroups gmane.comp.lang.ruby.core
Message-ID <redmine.journal-83394.20191225112012.49a3647a3f9929a7@ruby-lang.org>
Issue #15973 has been updated by zverok (Victor Shepelev).


> On a related note I think we should also prohibit `define_method(&non_lambda)` because that confusingly treats the same block body differently (e.g., the same return in the code means something different).

Seem it will have an awful impact on any DSLs?..

Like

```ruby
skip_if { |user| user.admin? }

# ...implemented as
def skip_if(&condition)
  define_method(:skip?, &condition)
end
```

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

* 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:[email protected]?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>