220 19943 <af534bd9-6a65-43c1-9c68-20d27cb0b96a@isocpp.org> article
Path: news.gmane.org!not-for-mail
From: Arthur Tchaikovsky <atch.cpp@gmail.com>
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Re: default arguments
Date: Thu, 20 Aug 2015 02:57:10 -0700 (PDT)
Lines: 186
Approved: news@gmane.org
Message-ID: <af534bd9-6a65-43c1-9c68-20d27cb0b96a@isocpp.org>
References: <ef9c7cbe-e8f1-4196-83bc-11a1c9b2798c@isocpp.org>
 <55D56B72.7010907@wanadoo.fr>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: plane.gmane.org
Mime-Version: 1.0
Content-Type: multipart/mixed; 
	boundary="----=_Part_2777_1614810103.1440064631073"
X-Trace: ger.gmane.org 1440064635 14020 80.91.229.3 (20 Aug 2015 09:57:15 GMT)
X-Complaints-To: usenet@ger.gmane.org
NNTP-Posting-Date: Thu, 20 Aug 2015 09:57:15 +0000 (UTC)
To: ISO C++ Standard - Future Proposals <std-proposals@isocpp.org>
Original-X-From: std-proposals+bncBDL6FI4NYYERB6GI22XAKGQES4FU23Y@isocpp.org Thu Aug 20 11:57:15 2015
Return-path: <std-proposals+bncBDL6FI4NYYERB6GI22XAKGQES4FU23Y@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-pa0-f72.google.com ([209.85.220.72])
	by plane.gmane.org with esmtp (Exim 4.69)
	(envelope-from <std-proposals+bncBDL6FI4NYYERB6GI22XAKGQES4FU23Y@isocpp.org>)
	id 1ZSMaw-0006aB-BR
	for gclcip-std-proposals@m.gmane.org; Thu, 20 Aug 2015 11:57:14 +0200
Original-Received: by pano2 with SMTP id o2sf8371180pan.3
        for <gclcip-std-proposals@m.gmane.org>; Thu, 20 Aug 2015 02:57:13 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=20120113;
        h=date:from:to:message-id:in-reply-to:references:subject:mime-version
         :content-type:x-original-sender:reply-to:precedence:mailing-list
         :list-id:x-spam-checked-in-group:list-post:list-help:list-archive
         :list-subscribe:list-unsubscribe;
        bh=VeoHfBgaylTkz5q6ing1WGTgej/2c49+ekh+tS3VVRQ=;
        b=dITIOGBkcciG6+BtY51/wpvO5SoQnrXnHFLodYSaz/NM/e84UrjOx3wQPa3JDqhBNl
         4RCjU5JN/V3Zc3jNm8zL+YRvrkE4qO4Lkq1EEJkYjvMNzPRbn4vBV63sUF3VBIeUwnop
         G+0+5kOyGyViTyPsrbKoXM5yk0ffqCbakSQiO2YA/K4i0+pMO3KN82VpHMyq4b5yzXpI
         eyGq91cKS+zNXjBf/RgqNiJrbSaoxP4QtOuJ+wc1/F+Ovo0Nit2qJaJZh6xMHpJQ23uT
         1Gz3l+wkkTCvLxzI6r6yXXOtWE4cma9oVuVD4PgK5lgv7H32D9QOtT7Tyw/pg4A6ovOT
         W08A==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20130820;
        h=x-gm-message-state:date:from:to:message-id:in-reply-to:references
         :subject:mime-version:content-type:x-original-sender:reply-to
         :precedence:mailing-list:list-id:x-spam-checked-in-group:list-post
         :list-help:list-archive:list-subscribe:list-unsubscribe;
        bh=VeoHfBgaylTkz5q6ing1WGTgej/2c49+ekh+tS3VVRQ=;
        b=iz8XycoZWXF9rXX8AsR+dQXJmx/t9KVSxcQ6GxVqF74ne1AkKr0KyHc7hBsPZifQ81
         HOjZj7ZMBqXVLwjPq6DtUQ4S8rtuFLXC0bR9SJm2jdf3bF6NnsXAoy/L2k5IROosdZ4V
         z9MmPw3U96qoAE/64jZuKE2bxytUXK2v2qGaetRbrxFFbrHWgY8eE/tqIYl1p54LCMub
         UDiYdGA7BSlqO13+5Z1Pkr/XIb/hq4OsY5DdjXv++wsC7Cs6QVc2VIYFsC04ePAmxVDq
         GnqNbrZtpLzNDpPt6ZTnnD7vDKQCwSeuGrP8oCUnZgHlON+L2nUFMhv9cgnKclc2W+f1
         n0Hw==
X-Gm-Message-State: ALoCoQlinnE0WnpO7zPb78Om4bPhNFCTKjSFb+M4HikNdcrtmNXVc55UuffLc7ERMX8AK+oq24N0
X-Received: by 10.68.104.161 with SMTP id gf1mr1607243pbb.11.1440064632969;
        Thu, 20 Aug 2015 02:57:12 -0700 (PDT)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.182.78.106 with SMTP id a10ls247812obx.43.gmail; Thu, 20 Aug
 2015 02:57:11 -0700 (PDT)
X-Received: by 10.182.105.34 with SMTP id gj2mr9789obb.34.1440064631954;
        Thu, 20 Aug 2015 02:57:11 -0700 (PDT)
In-Reply-To: <55D56B72.7010907@wanadoo.fr>
X-Original-Sender: atch.cpp@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:19943
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/19943>

------=_Part_2777_1614810103.1440064631073
Content-Type: multipart/alternative; 
	boundary="----=_Part_2778_268999758.1440064631073"

------=_Part_2778_268999758.1440064631073
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

Hi Vincente,
Thank you for your words.
As you yourself noted, the alternative is cumbersome and error prone. On=20
top of that, there is a huge amount of work left to the=20
designer/implementer of said function to provide all valid overloads which=
=20
I'm not sure that if real world devs would really go to such extend and do=
=20
it. With my proposal, all this burden, that is cumbersomeness, error=20
proneness and a work of developer/designer of such function are simply=20
removed. All is left is nice, natural syntax for users to use if they wish=
=20
to. I know that is my proposal and I shouldn't really say it, but I=20
genuinely fail to see bad/weak points of my proposal. It fits so nicely=20
with C++ both philosophy (give a choice) and syntax that I really hope this=
=20
will get voted into C++.

Thank you.

On Thursday, 20 August 2015 06:53:59 UTC+1, Vicente J. Botet Escriba wrote:
>
> Le 15/08/15 18:49, Arthur Tchaikovsky a =C3=A9crit :
>
> 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?
>
>
>
> 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 a=
n=20
> 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, ti=
meout, 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=
 useof the constants is however error prone.
>
> IMO, this kind of approach should appear in a possible proposal as your p=
roposal solves all the issues of this approach. =20
>
> 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/.

------=_Part_2778_268999758.1440064631073
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">Hi Vincente,<br>Thank you for your words.<br>As you yourse=
lf noted, the alternative is cumbersome and error prone. On top of that, th=
ere is a huge amount of work left to the designer/implementer of said funct=
ion to provide all valid overloads which I&#39;m not sure that if real worl=
d devs would really go to such extend and do it. With my proposal, all this=
 burden, that is cumbersomeness, error proneness and a work of developer/de=
signer of such function are simply removed. All is left is nice, natural sy=
ntax for users to use if they wish to. I know that is my proposal and I sho=
uldn&#39;t really say it, but I genuinely fail to see bad/weak points of my=
 proposal. It fits so nicely with C++ both philosophy (give a choice) and s=
yntax that I really hope this will get voted into C++.<br><br>Thank you.<br=
><br>On Thursday, 20 August 2015 06:53:59 UTC+1, Vicente J. Botet Escriba  =
wrote:<blockquote class=3D"gmail_quote" style=3D"margin: 0;margin-left: 0.8=
ex;border-left: 1px #ccc solid;padding-left: 1ex;">
 =20
   =20
 =20
  <div bgcolor=3D"#FFFFFF" text=3D"#000000">
    <div>Le 15/08/15 18:49, Arthur Tchaikovsky a
      =C3=A9crit=C2=A0:<br>
    </div>
    <blockquote type=3D"cite">
      <pre>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&#39;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>    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>
  </div>

</blockquote></div>

<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 />

------=_Part_2778_268999758.1440064631073--
------=_Part_2777_1614810103.1440064631073--

.
