From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS4713 221.184.0.0/13 X-Spam-Status: No, score=-3.7 required=3.0 tests=AWL,BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from neon.ruby-lang.org (neon.ruby-lang.org [221.186.184.75]) by dcvr.yhbt.net (Postfix) with ESMTP id 88FC41F454 for ; Mon, 4 Nov 2019 17:42:15 +0000 (UTC) Received: from neon.ruby-lang.org (localhost [IPv6:::1]) by neon.ruby-lang.org (Postfix) with ESMTP id ABC9F120970; Tue, 5 Nov 2019 02:42:04 +0900 (JST) Received: from o1678948x4.outbound-mail.sendgrid.net (o1678948x4.outbound-mail.sendgrid.net [167.89.48.4]) by neon.ruby-lang.org (Postfix) with ESMTPS id A969E12090A for ; Tue, 5 Nov 2019 02:42:01 +0900 (JST) Received: by filter0030p3iad2.sendgrid.net with SMTP id filter0030p3iad2-15594-5DC062ED-61 2019-11-04 17:42:05.662460313 +0000 UTC m=+326972.118735028 Received: from herokuapp.com (unknown [3.88.230.70]) by ismtpd0085p1mdw1.sendgrid.net (SG) with ESMTP id N5OtEg8VRkGxkX15YkShzQ for ; Mon, 04 Nov 2019 17:42:05.627 +0000 (UTC) Date: Mon, 04 Nov 2019 17:42:05 +0000 (UTC) From: merch-redmine@jeremyevans.net Message-ID: References: Mime-Version: 1.0 X-Redmine-MailingListIntegration-Message-Ids: 71265 X-Redmine-Project: ruby-trunk X-Redmine-Issue-Id: 11660 X-Redmine-Issue-Author: bughit X-Redmine-Sender: jeremyevans0 X-Mailer: Redmine X-Redmine-Host: bugs.ruby-lang.org X-Redmine-Site: Ruby Issue Tracking System X-Auto-Response-Suppress: All Auto-Submitted: auto-generated X-SG-EID: =?us-ascii?Q?RVE3t853K5scBhbmJHUzZTFFeVC=2FZSUmHZ0Dc+26wcEi2CTgsF1oz0wTSSxGGN?= =?us-ascii?Q?BIlEYljfCbrjy6+bsFihUlWt+5I=2FYqiCplPUulj?= =?us-ascii?Q?rf7kx1+DijfGbHzYcg0DA56h4DXBK8X=2FeOmthHP?= =?us-ascii?Q?rU9X0kqSTQ2OSOPo5Vmkpud8l2729HgSGDNl5Lo?= =?us-ascii?Q?qGsL0mow2StLw6RxPgwrwXe6cVHUpjF70EA=3D=3D?= To: ruby-core@ruby-lang.org X-ML-Name: ruby-core X-Mail-Count: 95673 Subject: [ruby-core:95673] [Ruby master Feature#11660] a falsy value (similar to js undefined) that facilitates forwarding of default arguments X-BeenThere: ruby-core@ruby-lang.org X-Mailman-Version: 2.1.15 Precedence: list Reply-To: Ruby developers List-Id: Ruby developers List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ruby-core-bounces@ruby-lang.org Sender: "ruby-core" 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/