From: merch-redmine@... Date: 2019-11-04T17:42:05+00:00 Subject: [ruby-core:95673] [Ruby master Feature#11660] a falsy value (similar to js undefined) that facilitates forwarding of default arguments Issue #11660 has been updated by jeremyevans0 (Jeremy Evans). bughit (bug hit) wrote: > The penalty the language pays is it has a demoware, checklist item, default value feature, where in any non-trivial scenario you have to produce the default value twice, first the intermediate default value through the default value expression, then the real default value in the body. There are many non-trivial scenarios where you don't need to do that (or we can have a no-true-Scotsman argument about the definition of non-trivial scenario). Most method calls do not involve calling methods that delegate arguments to another method where both methods have the same optional argument with the same default value. In the cases where that happens, the general practice is just to duplicate the default value in both methods, which is not usually an issue as default values are usually simple values or method calls. The only time you really want to have the "real default value" in the body is in fairly complex cases, and in those cases, the default argument values are usually set to `nil`. This is easy to understand and has worked well for Ruby for a long time. Ruby having a single `nil`, instead of JavaScript's `null` and `undefined`, is a net benefit, in my opinion. > You are not doing ruby any favors by defending this "design". You are not doing Ruby any favors by making a mountain out of a molehill. The popularity of an idea is not always a proxy to its merit, but if nobody else thinks the benefits of a proposal exceed the costs, maybe it isn't worth implementing. ---------------------------------------- Feature #11660: a falsy value (similar to js undefined) that facilitates forwarding of default arguments https://bugs.ruby-lang.org/issues/11660#change-82461 * Author: bughit (bug hit) * Status: Open * Priority: Normal * Assignee: * Target version: ---------------------------------------- I'll call it "missing" here. Consider the following scenario: ```ruby def foo(default1 = some_expression) end def bar(default1 = some_expression) foo default1 end def foobar(default1 = some_expression) bar default1 end ``` if you had "missing": ```ruby def foo(default1 = some_expression) end def bar(default1 = missing) foo default1 end def foobar(default1 = missing) bar default1 end ``` missing passed as arg would be ignored (as if it wasn't passed at all) and you wouldn't have to repeat the default value expression in every method I believe that's how undefined works in js6 with respect to default args -- https://bugs.ruby-lang.org/ Unsubscribe: