220 19890 <mqvdv7$6tc$1@ger.gmane.org> article
Path: news.gmane.org!not-for-mail
From: Matthew Woehlke <mwoehlke.floss@gmail.com>
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Re: default arguments
Date: Tue, 18 Aug 2015 10:03:18 -0400
Lines: 77
Approved: news@gmane.org
Message-ID: <mqvdv7$6tc$1@ger.gmane.org>
References: <ef9c7cbe-e8f1-4196-83bc-11a1c9b2798c@isocpp.org>	<CANu6V4UOxgZ9GV9f8DTbtW6BXrBPA7_2yUDRyhXv5BptvybHFA@mail.gmail.com>	<ab64c760-eeca-426a-953f-99d7a19919f6@isocpp.org> <CAD6_Qj_SkX1r_Egr0FHgk21ASVQuDkYrn1Cy7+dRAJFwHpG72w@mail.gmail.com>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: plane.gmane.org
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
X-Trace: ger.gmane.org 1439906625 7662 80.91.229.3 (18 Aug 2015 14:03:45 GMT)
X-Complaints-To: usenet@ger.gmane.org
NNTP-Posting-Date: Tue, 18 Aug 2015 14:03:45 +0000 (UTC)
To: std-proposals@isocpp.org
Original-X-From: std-proposals+bncBC37LBFWUIFBBN7WZSXAKGQETBSKJUY@isocpp.org Tue Aug 18 16:03:37 2015
Return-path: <std-proposals+bncBC37LBFWUIFBBN7WZSXAKGQETBSKJUY@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-lb0-f199.google.com ([209.85.217.199])
	by plane.gmane.org with esmtp (Exim 4.69)
	(envelope-from <std-proposals+bncBC37LBFWUIFBBN7WZSXAKGQETBSKJUY@isocpp.org>)
	id 1ZRhUH-0008Uo-A8
	for gclcip-std-proposals@m.gmane.org; Tue, 18 Aug 2015 16:03:37 +0200
Original-Received: by lbcue2 with SMTP id ue2sf7084793lbc.1
        for <gclcip-std-proposals@m.gmane.org>; Tue, 18 Aug 2015 07:03:37 -0700 (PDT)
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20130820;
        h=x-gm-message-state:to:from:subject:date:lines:message-id:references
         :mime-version:content-type:content-transfer-encoding:user-agent
         :in-reply-to:x-original-sender:x-original-authentication-results
         :reply-to:precedence:mailing-list:list-id:x-spam-checked-in-group
         :list-post:list-help:list-archive:list-subscribe:list-unsubscribe;
        bh=D2KBTKHIIuWGMlD56fh0qJ6ANujgV8KMuAePhTybC6M=;
        b=Mhjf9xoddUaexI6AJCwb+xb/WAbEZ+LP9Ho+I9FpnwqXrwwWxX17/JZbIBvGCqzxD1
         ozf7TUntZgX20kXmG02NpcrfIrJj3SmqFewvU9OwnPfgj3kH2eenzFTKZ9tTsrBWczS/
         fhdRZYyoDZVKqzotColnGZGibVFJFh9CLWfXbj3lI+TPonKq73JOWVjqL44UHjWbKQar
         yqUN6JQahnqgRw+VJiZqbuOCOdX8wHGeso2Sq8sbsa1d741Fe95tWWHXB8ctxCAlul28
         7ofrtp9gDY4flNUbyaThfXI5ZuweGdt+e1HSjdlL9oJNpZBo3AV 
X-Gm-Message-State: ALoCoQlWnEiA12nRTCrDwjdGdmQshP4QgI8I26bzZp6NKfWYWC0ob6NtRQIQHeOYY2RWJLFftEak
X-Received: by 10.180.90.106 with SMTP id bv10mr6374523wib.6.1439906616942;
        Tue, 18 Aug 2015 07:03:36 -0700 (PDT)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.152.88.7 with SMTP id bc7ls804697lab.74.gmail; Tue, 18 Aug
 2015 07:03:35 -0700 (PDT)
X-Received: by 10.112.210.137 with SMTP id mu9mr6265672lbc.95.1439906615010;
        Tue, 18 Aug 2015 07:03:35 -0700 (PDT)
Original-Received: from plane.gmane.org (plane.gmane.org. [80.91.229.3])
        by mx.google.com with ESMTPS id to6si14170247lbb.131.2015.08.18.07.03.34
        for <std-proposals@isocpp.org>
        (version=TLSv1 cipher=RC4-SHA bits=128/128);
        Tue, 18 Aug 2015 07:03:35 -0700 (PDT)
Received-SPF: pass (google.com: domain of gclcip-std-proposals@m.gmane.org designates 80.91.229.3 as permitted sender) client-ip=80.91.229.3;
Original-Received: from list by plane.gmane.org with local (Exim 4.69)
	(envelope-from <gclcip-std-proposals@m.gmane.org>)
	id 1ZRhUD-0008ST-R9
	for std-proposals@isocpp.org; Tue, 18 Aug 2015 16:03:34 +0200
Original-Received: from tripoint.kitware.com ([66.194.253.20])
        by main.gmane.org with esmtp (Gmexim 0.1 (Debian))
        id 1AlnuQ-0007hv-00
        for <std-proposals@isocpp.org>; Tue, 18 Aug 2015 16:03:33 +0200
Original-Received: from mwoehlke.floss by tripoint.kitware.com with local (Gmexim 0.1 (Debian))
        id 1AlnuQ-0007hv-00
        for <std-proposals@isocpp.org>; Tue, 18 Aug 2015 16:03:33 +0200
X-Injected-Via-Gmane: http://gmane.org/
Original-Lines: 57
Original-X-Complaints-To: usenet@ger.gmane.org
X-Gmane-NNTP-Posting-Host: tripoint.kitware.com
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.7.0
In-Reply-To: <CAD6_Qj_SkX1r_Egr0FHgk21ASVQuDkYrn1Cy7+dRAJFwHpG72w@mail.gmail.com>
X-Original-Sender: mwoehlke.floss@gmail.com
X-Original-Authentication-Results: mx.google.com;       spf=pass (google.com:
 domain of gclcip-std-proposals@m.gmane.org designates 80.91.229.3 as
 permitted sender) smtp.mailfrom=gclcip-std-proposals@m.gmane.org;
       dmarc=fail (p=NONE dis=NONE) header.from=gmail.com
Precedence: list
Mailing-list: list std-proposals@isocpp.org; contact std-proposals+owners@isocpp.org
List-ID: <std-proposals.isocpp.org>
X-Spam-Checked-In-Group: std-proposals@isocpp.org
X-Google-Group-Id: 399137483710
List-Post: <http://groups.google.com/a/isocpp.org/group/std-proposals/post>, <mailto:std-proposals@isocpp.org>
List-Help: <http://support.google.com/a/isocpp.org/bin/topic.py?topic=25838>, <mailto:std-proposals+help@isocpp.org>
List-Archive: <http://groups.google.com/a/isocpp.org/group/std-proposals/>
List-Subscribe: <http://groups.google.com/a/isocpp.org/group/std-proposals/subscribe>,
 <mailto:std-proposals+subscribe@isocpp.org>
List-Unsubscribe: <mailto:googlegroups-manage+399137483710+unsubscribe@googlegroups.com>,
 <http://groups.google.com/a/isocpp.org/group/std-proposals/subscribe>
Xref: news.gmane.org gmane.comp.lang.c++.isocpp.proposals:19890
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/19890>

On 2015-08-18 06:22, David Rodr=C3=ADguez Ibeas wrote:
> On Tue, Aug 18, 2015 at 10:42 AM, Arthur Tchaikovsky wrote:
>> On Tuesday, 18 August 2015 10:34:39 UTC+1, Johannes Schaub wrote:
>>> I would also wanna solve this with named arguments
>>>
>>>   f(.b =3D 2, .d =3D 4)
>>
>> That genuinely seems pointless/silly to me, unless you can provide some
>> convincing use cases.
>
> Any use case in which you may end up using 'default' in your proposal is =
a
> use case for these two approaches.  In the first case, it lets you focus =
on
> what parameters are being configured (rather than defaulted) without havi=
ng
> to look at the function declaration, 'f(.b =3D 2, .d =3D 4)' is equivalen=
t to
> 'f(default, 2, default, 4)' and I find the former easier to read.

It's also self-documenting. Consider Arthur O'Dwyer's examples; which is
easier to understand?

  auto cptr =3D new C();         // usually the defaults are okay
  auto c2ptr =3D new C(2048);    // use a bigger buffer
  auto c3ptr =3D new C(default, 1); // use a shorter timeout

- vs. -

  auto cptr =3D new C{};
  auto c2ptr =3D new C{.buffer =3D 2048};
  auto c3ptr =3D new C{.timeout =3D 1};

There's a reason named arguments are so popular in Python :-).

> int a[10] =3D { [3] =3D 1, [2] =3D 5, 6 }; // what values are in the arra=
y?

This never happens because your example is ill-formed. Parameters that
are neither named nor indexed must precede parameters that are. (In
Python also, and for similar reasons.)

> Still, that might be easier than implementing named arguments.  The "name=
d"
> arguments work nicely with a 'struct' since the type can be defined only
> once, but it leads to different sorts of confusion for functions that may
> have multiple declarations:
>=20
> void f(int a =3D 1, int b =3D 2);
> void f(int b =3D 1, int a =3D 2);  // redeclaration
>=20
> Which AFAIK is one of the issues that this form of proposals have faced i=
n
> the past.  I recall also some discussions in this forum (or maybe even
> papers?) aiming for a syntax that would allow this by enabling
> warning/errors when a redeclaration used different names than the origina=
l
> declaration but I did not see any of those prosper.

Probably there should be a way of naming parameters that "codifies" the
name, making it part of the ABI. And, yes, such redeclarations would be
disallowed.

--=20
Matthew

--=20

---=20
You received this message because you are subscribed to the Google Groups "=
ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposa=
ls/.

.
