220 19939 <55D56B72.7010907@wanadoo.fr> article
Path: news.gmane.org!not-for-mail
From: "Vicente J. Botet Escriba" <vicente.botet@wanadoo.fr>
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Re: default arguments
Date: Thu, 20 Aug 2015 07:53:54 +0200
Lines: 143
Approved: news@gmane.org
Message-ID: <55D56B72.7010907@wanadoo.fr>
References: <ef9c7cbe-e8f1-4196-83bc-11a1c9b2798c@isocpp.org>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: plane.gmane.org
Mime-Version: 1.0
Content-Type: multipart/alternative;
 boundary="------------030205020903080201030404"
X-Trace: ger.gmane.org 1440050050 15440 80.91.229.3 (20 Aug 2015 05:54:10 GMT)
X-Complaints-To: usenet@ger.gmane.org
NNTP-Posting-Date: Thu, 20 Aug 2015 05:54:10 +0000 (UTC)
To: std-proposals@isocpp.org
Original-X-From: std-proposals+bncBDH67CONY4PBB5GW2WXAKGQEZ5RQB5A@isocpp.org Thu Aug 20 07:54:01 2015
Return-path: <std-proposals+bncBDH67CONY4PBB5GW2WXAKGQEZ5RQB5A@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-la0-f69.google.com ([209.85.215.69])
	by plane.gmane.org with esmtp (Exim 4.69)
	(envelope-from <std-proposals+bncBDH67CONY4PBB5GW2WXAKGQEZ5RQB5A@isocpp.org>)
	id 1ZSInW-0005FO-LP
	for gclcip-std-proposals@m.gmane.org; Thu, 20 Aug 2015 07:53:58 +0200
Original-Received: by labpx14 with SMTP id px14sf7865465lab.1
        for <gclcip-std-proposals@m.gmane.org>; Wed, 19 Aug 2015 22:53:58 -0700 (PDT)
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20130820;
        h=x-gm-message-state:subject:to:references:from:message-id:date
         :user-agent:mime-version:in-reply-to:content-type: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=gbHEPm1z3DU6/GUsQyAKNOVbcUAg489NEMHhGuA80Nc=;
        b=G7bJbwv6j9FzQZr9jDU7jsDKt1QMLjoYJ3P6E3id0TBVB7MgN5J+uExvQwNCBcESx7
         rHYQddgd9p8wLXkDGZpIt869fTKoAX1K/04bvUMbCJg9YaG9k5hYMH19aoE3S8+dp1QI
         Fgk+e7fwGkgql4j4miD1MN3/ZTArdKLGXDaSxthh6u+y8PQXByklOtryuppPkYrSzowD
         tIiUt5MnN0olyEWzqTaHADvWAA0x3Mu8OPAZK7vvRcUKcNUy+LJGpY+81zBtw6m1CbeI
         C5dYYQx7s6M5FALDIjs5FnxMJPAjoCvbDL1fVyRq795oRwYEdXrdywLf6e4KkMgROCkJ
         fFCw= 
X-Gm-Message-State: ALoCoQlkecZo2rfNxPTO5MFmrzKBcXsP1M+gEpBN9d+JuDnSdJJGFG08Mt6uHzRB53yF9HRIsJdE
X-Received: by 10.194.115.135 with SMTP id jo7mr340702wjb.7.1440050038010;
        Wed, 19 Aug 2015 22:53:58 -0700 (PDT)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.180.106.5 with SMTP id gq5ls53495wib.31.gmail; Wed, 19 Aug
 2015 22:53:55 -0700 (PDT)
X-Received: by 10.194.85.130 with SMTP id h2mr2790789wjz.2.1440050035532;
        Wed, 19 Aug 2015 22:53:55 -0700 (PDT)
Original-Received: from smtp.smtpout.orange.fr (smtp04.smtpout.orange.fr. [80.12.242.126])
        by mx.google.com with ESMTPS id e16si7148674wiv.48.2015.08.19.22.53.55
        for <std-proposals@isocpp.org>
        (version=TLSv1 cipher=RC4-SHA bits=128/128);
        Wed, 19 Aug 2015 22:53:55 -0700 (PDT)
Received-SPF: neutral (google.com: 80.12.242.126 is neither permitted nor denied by best guess record for domain of vicente.botet@wanadoo.fr) client-ip=80.12.242.126;
Original-Received: from new-host.home ([81.53.62.61])
	by mwinf5d51 with ME
	id 6ttu1r0091KGt4H03ttume; Thu, 20 Aug 2015 07:53:55 +0200
X-ME-Helo: new-host.home
X-ME-Auth: dmljZW50ZS5ib3RldEB3YW5hZG9vLmZy
X-ME-Date: Thu, 20 Aug 2015 07:53:55 +0200
X-ME-IP: 81.53.62.61
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7; rv:38.0)
 Gecko/20100101 Thunderbird/38.2.0
In-Reply-To: <ef9c7cbe-e8f1-4196-83bc-11a1c9b2798c@isocpp.org>
X-Original-Sender: vicente.botet@wanadoo.fr
X-Original-Authentication-Results: mx.google.com;       spf=neutral
 (google.com: 80.12.242.126 is neither permitted nor denied by best guess
 record for domain of vicente.botet@wanadoo.fr) smtp.mailfrom=vicente.botet@wanadoo.fr
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:19939
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/19939>

This is a multi-part message in MIME format.
--------------030205020903080201030404
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: quoted-printable

Le 15/08/15 18:49, Arthur Tchaikovsky a =C3=A9crit :
> Hi,
> Does anyone see helpfulness of such solution:
> Having fnc:
>
> void f(int a =3D 0, int b =3D 1, int c =3D 2, int d =3D 3);
>
> I think that it would be nice to be able to say whilst calling it and
> requiring only some of those args to be non-default:
>
> f(default,2,default,4);
>
> Thoughts?
>
>
Hi, note that I'm not against the proposal.

Just wanted to share a way to do what you are proposing in C++14. It is=20
an alternative that is cumbersome and error prone. It consist in using=20
overloading and a default_t type and a default_ instance of default_t.

     f(int buffer_size =3D 1024, int timeout =3D 10, int tries =3D 3);
     f(default_t, int timeout =3D 10, int tries =3D 3) { return f(1024, tim=
eout, tries); }
     f(int buffer_size, default_t, int tries =3D 3) { return f(buffer_size,=
 10, tries); }

f();
f(default_, 0);
f(default_, default_, 20);

The function provider can use constant for the defaults of course but the u=
seof the constants is however error prone.

IMO, this kind of approach should appear in a possible proposal as your pro=
posal solves all the issues of this approach.

Vicente





--=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/.

--------------030205020903080201030404
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<html>
  <head>
    <meta content=3D"text/html; charset=3Dutf-8" http-equiv=3D"Content-Type=
">
  </head>
  <body bgcolor=3D"#FFFFFF" text=3D"#000000">
    <div class=3D"moz-cite-prefix">Le 15/08/15 18:49, Arthur Tchaikovsky a
      =C3=A9crit=C2=A0:<br>
    </div>
    <blockquote
      cite=3D"mid:ef9c7cbe-e8f1-4196-83bc-11a1c9b2798c@isocpp.org"
      type=3D"cite">
      <pre wrap=3D"">Hi,=20
Does anyone see helpfulness of such solution:
Having fnc:

void f(int a =3D 0, int b =3D 1, int c =3D 2, int d =3D 3);

I think that it would be nice to be able to say whilst calling it and=20
requiring only some of those args to be non-default:

f(default,2,default,4);

Thoughts?


</pre>
    </blockquote>
    <font size=3D"+1">Hi, note that I'm not against the proposal.<br>
      <br>
      Just wanted to share a way to do what you are proposing in C++14.
      It is an alternative that is cumbersome and error prone. It
      consist in using overloading and a default_t type and a default_
      instance of default_t.</font><br>
    <br>
    <pre wrap=3D"">    f(int buffer_size =3D 1024, int timeout =3D 10, int =
tries =3D 3);
    f(default_t, int timeout =3D 10, int tries =3D 3) { return f(1024, time=
out, tries); }
    f(int buffer_size, default_t, int tries =3D 3) { return f(buffer_size, =
10, tries); }

f();
f(default_, 0);
f(default_, default_, 20);

The function provider can use constant for the defaults of course but the u=
seof the constants is however error prone.

IMO, this kind of approach should appear in a possible proposal as your pro=
posal solves all the issues of this approach. =20

Vicente




</pre>
    <br>
  </body>
</html>

<p></p>

-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals&quot; group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />

--------------030205020903080201030404--

.
