220 19872 <55D2BEC3.9070307@eudoxos.de> article
Path: news.gmane.org!not-for-mail
From: Roland Bock <rbock@eudoxos.de>
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Re: Re: default arguments
Date: Tue, 18 Aug 2015 07:12:35 +0200
Lines: 597
Approved: news@gmane.org
Message-ID: <55D2BEC3.9070307@eudoxos.de>
References: <ef9c7cbe-e8f1-4196-83bc-11a1c9b2798c@isocpp.org> <736eb378-52a4-43ba-b3b5-a73719ba70af@isocpp.org> <mqtask$51j$1@ger.gmane.org> <86717349-1fce-4247-9372-08eedce4cd30@isocpp.org>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: plane.gmane.org
Mime-Version: 1.0
Content-Type: multipart/alternative;
 boundary="------------010403090403020403070202"
X-Trace: ger.gmane.org 1439874767 24071 80.91.229.3 (18 Aug 2015 05:12:47 GMT)
X-Complaints-To: usenet@ger.gmane.org
NNTP-Posting-Date: Tue, 18 Aug 2015 05:12:47 +0000 (UTC)
To: std-proposals@isocpp.org
Original-X-From: std-proposals+bncBCO7PYWVVELRBRP5ZKXAKGQE75N6OVI@isocpp.org Tue Aug 18 07:12:39 2015
Return-path: <std-proposals+bncBCO7PYWVVELRBRP5ZKXAKGQE75N6OVI@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+bncBCO7PYWVVELRBRP5ZKXAKGQE75N6OVI@isocpp.org>)
	id 1ZRZCQ-0003KO-O5
	for gclcip-std-proposals@m.gmane.org; Tue, 18 Aug 2015 07:12:38 +0200
Original-Received: by lbcli1 with SMTP id li1sf51866352lbc.2
        for <gclcip-std-proposals@m.gmane.org>; Mon, 17 Aug 2015 22:12:38 -0700 (PDT)
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20130820;
        h=x-gm-message-state:message-id:date:from:user-agent:mime-version:to
         :subject:references: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=WUikQ8oXJA1e2QyGIoNMKelX6OGPOqeIGd8rx1V2vX0=;
        b=NzX21Ry4XBG7gZhrzLBw+gd8h9Ra/JhBKbIsMbi04Zlim+mnjkIiaX6KigmyEC9/TY
         i7VXaAQlM22pm68MDHpTDkCK6wVovQ/oxxtOqwoH7+tgscyJnD7N5RR0WB76RBMTVQlL
         RP22XfkTzvCONId3munPKOU+Is+tu4i/T2MxMbpS7JG4IWKKf7FUV38owmFz2WZJml3D
         igrX0/d+LMyLb20IlS5aNy/T2mHx1CIAivCgddxUoDJOlnRTBwXPTmq+yfurNcMjO4Kv
         Btp94zDWf6JrrVSrKebNpZxntH8AZBgjOqpioMW249Ro3QUZcHcC89KGgLccz5Jci7mF
         HKAw= 
X-Gm-Message-State: ALoCoQneJnWlwtAds5LjF2WEspINTcO+zV61/FlNI7sd17Y0f1/PApev9rGLhBdwwZWhvTG7TeQq
X-Received: by 10.194.93.198 with SMTP id cw6mr1238871wjb.3.1439874758264;
        Mon, 17 Aug 2015 22:12:38 -0700 (PDT)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.180.90.209 with SMTP id by17ls708892wib.12.canary; Mon, 17 Aug
 2015 22:12:37 -0700 (PDT)
X-Received: by 10.194.117.5 with SMTP id ka5mr9140497wjb.50.1439874757124;
        Mon, 17 Aug 2015 22:12:37 -0700 (PDT)
Original-Received: from mout.kundenserver.de (mout.kundenserver.de. [212.227.126.187])
        by mx.google.com with ESMTPS id eu3si24836567wic.47.2015.08.17.22.12.37
        for <std-proposals@isocpp.org>
        (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);
        Mon, 17 Aug 2015 22:12:37 -0700 (PDT)
Received-SPF: neutral (google.com: 212.227.126.187 is neither permitted nor denied by best guess record for domain of rbock@eudoxos.de) client-ip=212.227.126.187;
Original-Received: from [172.30.200.118] ([194.97.158.70]) by mrelayeu.kundenserver.de
 (mreue004) with ESMTPSA (Nemesis) id 0Ll1qT-1YtbQP0ZfB-00al4t for
 <std-proposals@isocpp.org>; Tue, 18 Aug 2015 07:12:36 +0200
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.8.0
In-Reply-To: <86717349-1fce-4247-9372-08eedce4cd30@isocpp.org>
X-Provags-ID: V03:K0:RUKkBehIuPtDt8voFKPyDBYy0QF0NY+Zz2Qb0lTDA0gObf++b5u
 WxmrJLFgXevzKgahXCDQYgKrG9uQZbsbWtl98OvZ1POsFpES++jGUI2EjFHYvNQlWaKuy9y
 cBcAU6Wrk2EdJtfSz1sUaq6ydSBnza9p84U5rwTCf0Dm1Tmrm2hG8IBNeQaJQjGOR/ABJ5M
 S+ILsG71pRp9s991YK57Q==
X-UI-Out-Filterresults: notjunk:1;V01:K0:y90/5qpZCTc=:y+7urK71LVZQBJoL216lj8
 tAxQDpE3ndZ3AiYs1PArfiWyJtgOKeEh0R3QeAWX5R72YsJR+P9L1Jzqv/Qq+O7OvOdyQaNaL
 yCvlag3hUOnRIJQoMrTgAIqxR+R4CsYE5YdIC/RuOTUnkTJ9VYzRR/iDDuLQsKVLIkSVHlv0s
 HZg6Gi4cCs1wndP04xzOivhv1Ypp2Hb7z8X3IPHgSUT2oGhl9Xr/66L2xppU9ybk+/0b+4j1j
 gLwbos2/W5VAazVP5D08cDRnUINv5jtyHs6zDSUufVjfSmLH66lT8A/HvT0wHjDI/lI3lKrBL
 WgCLxOBHqr2p7fu0iQq1t2JgEY/9v4izjcM8imbzSKw/yn/DRNAVrHcUoxvIA6TKw2wOj7GBf
 zDjeCxdmBDtt2VOjt2rqdPYdQ94v3I9cpw8Xzk/YznrB+5L1BdcEb9BdmYZ9zDJPhzyXvSt5y
 RfhFn/OXwwrV+tEhGaByNip3+Hjqnz7N6hr6fN6UFSg1Md+rHgVfaFcrd95jZT9JaCChiWfMU
 nV+zenWeCu1UNBIxQR+lHBWS3gJ2iB2XH6IRHg7/t972Q48bKSt240x8Mg4bfD0jsN+jQ+7tE
 wgca4RA980YfDCIkMtkqQo+apHHYRNIIxyxBN75zCUD4Gd1jNJbybAnxBWUZgV23CI3iwGEnL
 m3CVajVffuhk4PW04IhzXDtI/837FTA1f+zrcEBI6t4/s3ItrH01ON+vFHCWVj7ZSnyVvxYg8
 O5nrUMc11VnTqB0g
X-Original-Sender: rbock@eudoxos.de
X-Original-Authentication-Results: mx.google.com;       spf=neutral
 (google.com: 212.227.126.187 is neither permitted nor denied by best guess
 record for domain of rbock@eudoxos.de) smtp.mailfrom=rbock@eudoxos.de
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:19872
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/19872>

This is a multi-part message in MIME format.
--------------010403090403020403070202
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

On 2015-08-18 00:52, Arthur O'Dwyer wrote:
> I work on a codebase where this feature would have lots of use-cases,
> because we have lots of classes whose constructors have defaulted
> parameters:
>
>     C(int buffer_size =3D 1024, int timeout =3D 10, int tries =3D 3) :
> buffer_size_(buffer_size), timeout_(timeout), tries_(tries) {}
>
>     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(1024, 1);  // use the default buffer size but
> with a shorter timeout
>     auto c4ptr =3D new C(2048, 10, 5);  // testing: bump up the number
> of tries
>
> It would be marginally more convenient (and refactor-proof) to be able
> to write
>
>     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 the default buffer size
> but with a shorter timeout
>     auto c4ptr =3D new C(2048, default, 5);  // testing: bump up the
> number of tries
>
> However, I consider defaulted parameters in general to be a huge
> antipattern, and this constructor pattern in particular to be even worse.

+10 (at least)

> I would MUCH rather just rewrite all these constructors so that they
> could be used as
>
>     auto cptr =3D new C();  // usually the defaults are okay
>     auto c2ptr =3D new C().withBufferSize(2048);  // use a bigger buffer
>     auto c3ptr =3D new C().withTimeout(1);  // use the default buffer
> size but with a shorter timeout
>     auto c4ptr =3D new C().withBufferSize(2048).withTries(5);  //
> testing: bump up the number of tries
>
> or
>
>     auto cptr =3D new C();  // usually the defaults are okay
>     auto c2ptr =3D new C(C::BufferSize(2048));  // use a bigger buffer
>     auto c3ptr =3D new C(C::Timeout(1));  // use the default buffer size
> but with a shorter timeout
>     auto c4ptr =3D new C(C::BufferSize(2048), C::Tries(5));  // testing:
> bump up the number of tries

Or (if you are definining individual types for your parameters anyway),
why not

    auto cptr =3D new C();  // usually the defaults are okay
    auto c2ptr =3D new C(bufferSize =3D 2048);  // use a bigger buffer
    auto c3ptr =3D new C(timeout =3D 1);  // use the default buffer size bu=
t
with a shorter timeout
    auto c4ptr =3D new C(bufferSize =3D 2048, tries =3D 5);  // testing: bu=
mp
up the number of tries

You would have but one constructor (assuming Concepts Lite and Folding
Expressions):

template<Assignment... A)
C(const A&... a) : buffer_size_(1024), timeout_(10), tries_(3)
{
  (a(*this),...);
}

And some types/constexprs:

struct BufferSizeAssignment
{
   int value;

   template<typename T>
   void operator()(T& t)
   {
      t.buffer_size_ =3D value;// or t.setBufferSize(value)
   }
};

struct BufferSize
{
   BufferSizeAssignment operator=3D(int value)
   {
      return {value};
   }
};

constexpr auto bufferSize =3D BufferSize{};


Of course, this would be much more convenient if we could configure
names in template parameters and could write

constexpr auto bufferSize =3D std::named_parameter<int, `buffer_size_`>;
constexpr auto timeout =3D std::named_parameter<int, `timeout_`>;
constexpr auto tries =3D std::named_parameter<int, `tries_`>;

Still trying to find the time to write the proposal for that...


Best,

Roland

>
> or (the most conservative way to rewrite our existing code)
>
>     static constexpr int default_buffer_size =3D 1024;
>     static constexpr int default_timeout =3D 10;
>     static constexpr int default_tries =3D 3;
>     C() : buffer_size_(default_buffer_size),
> timeout_(default_timeout), tries_(default_tries) {}
>     C(int buffer_size, int timeout, int tries) :
> buffer_size_(buffer_size), timeout_(timeout), tries_(tries) {}
>
>     auto cptr =3D new C();  // usually the defaults are okay
>     auto c2ptr =3D new C(2048, C::default_timeout, C::default_tries);
>  // use a bigger buffer
>     auto c3ptr =3D new C(C::default_buffer_size, 1, C::default_tries);
>  // use the default buffer size but with a shorter timeout
>     auto c4ptr =3D new C(2048, C::default_timeout, 5);  // testing: bump
> up the number of tries
>
> I don't really want to make it /easier/ for people to write the
> "function taking tons of defaulted parameters" antipattern.
> Let's teach people how to avoid the use of defaulted parameters, instead.
>
> =E2=80=93Arthur
>
>
> On Monday, August 17, 2015 at 11:58:41 AM UTC-7, Bo Persson wrote:
>
>     On 2015-08-17 20:37, Arthur Tchaikovsky wrote:
>     > I would really appreciate some feedback from people, or is this
>     proposal
>     > so uninteresting that there is no point in wasting keyboard on it?
>
>     You might wonder how widely used it will be?
>
>     If not all parameters are of the same type, you can already get
>     some of
>     the effect with a few overloads:
>
>          void f(int a =3D 0, string b =3D "1",
>                 complex<double> c =3D 2.0, type4 d =3D 3);
>
>          inline void f(int a, complex<double> c)
>          { f(a, "1", c, 3); }
>
>          inline void f(string b, complex<double> c)
>          { f(0, b, c, 3); }
>
>     assuming that d is put last because you hardly ever want to change
>     the
>     default.
>
>     Just saying that you can already do this without a language change.
>
>
>         Bo Persson
>
>
>
>     >
>     > On Saturday, 15 August 2015 17:49:50 UTC+1, Arthur Tchaikovsky
>     wrote:
>     >
>     >     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?
>     >
>     >
>
>
> --=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 email to std-proposals+unsubscribe@isocpp.org
> <mailto:std-proposals+unsubscribe@isocpp.org>.
> To post to this group, send email to std-proposals@isocpp.org
> <mailto:std-proposals@isocpp.org>.
> Visit this group at
> http://groups.google.com/a/isocpp.org/group/std-proposals/.

--=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/.

--------------010403090403020403070202
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">On 2015-08-18 00:52, Arthur O'Dwyer
      wrote:<br>
    </div>
    <blockquote
      cite=3D"mid:86717349-1fce-4247-9372-08eedce4cd30@isocpp.org"
      type=3D"cite">
      <div dir=3D"ltr">I work on a codebase where this feature would have
        lots of use-cases, because we have lots of classes whose
        constructors have defaulted parameters:
        <div><br>
        </div>
        <div>=C2=A0 =C2=A0 C(int buffer_size =3D 1024, int timeout =3D 10, =
int tries =3D
          3) : buffer_size_(buffer_size), timeout_(timeout),
          tries_(tries) {}</div>
        <div><br>
        </div>
        <div>=C2=A0 =C2=A0 auto cptr =3D new C(); =C2=A0// usually the defa=
ults are okay</div>
        <div>=C2=A0 =C2=A0 auto c2ptr =3D new C(2048); =C2=A0// use a bigge=
r buffer<br>
          =C2=A0 =C2=A0 auto c3ptr =3D new C(1024, 1); =C2=A0// use the def=
ault buffer
          size but with a shorter timeout</div>
        <div>=C2=A0 =C2=A0 auto c4ptr =3D new C(2048, 10, 5); =C2=A0// test=
ing: bump up
          the number of tries</div>
        <div><br>
        </div>
        <div>It would be marginally more convenient (and refactor-proof)
          to be able to write</div>
        <div><br>
        </div>
        <div>
          <div>=C2=A0 =C2=A0 auto cptr =3D new C(); =C2=A0// usually the de=
faults are
            okay</div>
          <div>=C2=A0 =C2=A0 auto c2ptr =3D new C(2048); =C2=A0// use a big=
ger buffer<br>
            =C2=A0 =C2=A0 auto c3ptr =3D new C(default, 1); =C2=A0// use th=
e default
            buffer size but with a shorter timeout</div>
          <div>=C2=A0 =C2=A0 auto c4ptr =3D new C(2048,=C2=A0default, 5); =
=C2=A0// testing:
            bump up the number of tries</div>
          <div><br>
          </div>
          <div>However, I consider defaulted parameters in general to be
            a huge antipattern, and this constructor pattern in
            particular to be even worse.</div>
        </div>
      </div>
    </blockquote>
    <br>
    +10 (at least)<br>
    <br>
    <blockquote
      cite=3D"mid:86717349-1fce-4247-9372-08eedce4cd30@isocpp.org"
      type=3D"cite">
      <div dir=3D"ltr">
        <div>
          <div>I would MUCH rather just rewrite all these constructors
            so that they could be used as</div>
          <div><br>
          </div>
          <div>=C2=A0 =C2=A0 auto cptr =3D new C(); =C2=A0// usually the de=
faults are
            okay</div>
          <div>=C2=A0 =C2=A0 auto c2ptr =3D new C().withBufferSize(2048); =
=C2=A0// use a
            bigger buffer<br>
            =C2=A0 =C2=A0 auto c3ptr =3D new C().withTimeout(1); =C2=A0// u=
se the default
            buffer size but with a shorter timeout</div>
          <div>=C2=A0 =C2=A0 auto c4ptr =3D new
            C().withBufferSize(2048).withTries(5); =C2=A0// testing: bump u=
p
            the number of tries</div>
          <div><br>
          </div>
          <div>or</div>
          <div><br>
          </div>
          <div>
            <div>=C2=A0 =C2=A0 auto cptr =3D new C(); =C2=A0// usually the =
defaults are
              okay</div>
            <div>=C2=A0 =C2=A0 auto c2ptr =3D new C(C::BufferSize(2048)); =
=C2=A0// use a
              bigger buffer<br>
              =C2=A0 =C2=A0 auto c3ptr =3D new C(C::Timeout(1)); =C2=A0// u=
se the default
              buffer size but with a shorter timeout</div>
            <div>=C2=A0 =C2=A0 auto c4ptr =3D new C(C::BufferSize(2048),
              C::Tries(5)); =C2=A0// testing: bump up the number of tries</=
div>
          </div>
        </div>
      </div>
    </blockquote>
    <br>
    Or (if you are definining individual types for your parameters
    anyway), why not <br>
    <br>
    <div>
      <div><tt>=C2=A0 =C2=A0 auto cptr =3D new C(); =C2=A0// usually the de=
faults are
          okay</tt></div>
      <div><tt>=C2=A0 =C2=A0 auto c2ptr =3D new C(bufferSize =3D 2048); =C2=
=A0// use a
          bigger buffer</tt><tt><br>
        </tt><tt>=C2=A0 =C2=A0 auto c3ptr =3D new C(timeout =3D 1); =C2=A0/=
/ use the
          default buffer size but with a shorter timeout</tt></div>
      <div><tt>=C2=A0 =C2=A0 auto c4ptr =3D new C(bufferSize =3D 2048, trie=
s =3D 5); =C2=A0//
          testing: bump up the number of tries</tt></div>
    </div>
    <br>
    You would have but one constructor (assuming Concepts Lite and
    Folding Expressions):<br>
    <br>
    <tt>template&lt;Assignment... A</tt><tt>)</tt><tt><br>
    </tt><tt>C(const A&amp;... a) : buffer_size_(1024), timeout_(10),
      tries_(3)</tt><tt><br>
    </tt><tt>{</tt><tt><br>
    </tt><tt>=C2=A0 (a(*this),...);</tt><tt><br>
    </tt><tt>}</tt><br>
    <br>
    And some types/constexprs:<br>
    <br>
    <tt>struct BufferSizeAssignment</tt><tt><br>
    </tt><tt>{</tt><tt><br>
    </tt><tt>=C2=A0=C2=A0 int value;</tt><tt><br>
    </tt><tt><br>
    </tt><tt>=C2=A0=C2=A0 template&lt;typename T&gt;</tt><tt><br>
    </tt><tt>=C2=A0=C2=A0 void operator()(T&amp; t)</tt><tt><br>
    </tt><tt>=C2=A0=C2=A0 {</tt><tt><br>
    </tt><tt>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 t.buffer_size_ =3D value;</tt><=
tt> // or
      t.setBufferSize(value)<br>
    </tt><tt>=C2=A0=C2=A0 }</tt><tt><br>
    </tt><tt>};</tt><tt><br>
    </tt><tt><br>
    </tt><tt>struct BufferSize</tt><tt><br>
    </tt><tt>{</tt><tt><br>
    </tt><tt>=C2=A0=C2=A0 BufferSizeAssignment operator=3D(int value)</tt><=
tt><br>
    </tt><tt>=C2=A0=C2=A0 {</tt><tt><br>
    </tt><tt>=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 return {value};</tt><tt><br>
    </tt><tt>=C2=A0=C2=A0 }</tt><tt><br>
    </tt><tt>};</tt><tt><br>
    </tt><tt><br>
    </tt><tt>constexpr auto bufferSize =3D BufferSize{};</tt><tt><br>
    </tt><br>
    <br>
    Of course, this would be much more convenient if we could configure
    names in template parameters and could write<br>
    <br>
    <tt>constexpr auto bufferSize =3D std::named_parameter&lt;int,
      `buffer_size_`&gt;;</tt><tt><br>
    </tt><tt>
      constexpr auto timeout =3D std::named_parameter&lt;int,
      `timeout_`&gt;;</tt><tt><br>
    </tt><tt>constexpr auto tries =3D std::named_parameter&lt;int,
      `tries_`&gt;;</tt><tt><br>
    </tt><br>
    Still trying to find the time to write the proposal for that...<br>
    <br>
    <br>
    Best,<br>
    <br>
    Roland<br>
    <br>
    <blockquote
      cite=3D"mid:86717349-1fce-4247-9372-08eedce4cd30@isocpp.org"
      type=3D"cite">
      <div dir=3D"ltr">
        <div>
          <div><br>
          </div>
          <div>or (the most conservative way to rewrite our existing
            code)</div>
          <div><br>
          </div>
          <div>=C2=A0 =C2=A0 static constexpr int default_buffer_size =3D 1=
024;</div>
          <div>=C2=A0 =C2=A0 static constexpr int default_timeout =3D 10;</=
div>
          <div>=C2=A0 =C2=A0 static constexpr int default_tries =3D 3;</div=
>
          <div>=C2=A0 =C2=A0 C() : buffer_size_(default_buffer_size),
            timeout_(default_timeout), tries_(default_tries) {}<br>
          </div>
          <div>
            <div>
              <div>=C2=A0 =C2=A0 C(int buffer_size, int timeout, int tries)=
 :
                buffer_size_(buffer_size), timeout_(timeout),
                tries_(tries) {}</div>
            </div>
          </div>
          <div><br>
          </div>
          <div>=C2=A0 =C2=A0 auto cptr =3D new C(); =C2=A0// usually the de=
faults are
            okay<br>
          </div>
          <div>
            <div>=C2=A0 =C2=A0 auto c2ptr =3D new C(2048, C::default_timeou=
t,
              C::default_tries); =C2=A0// use a bigger buffer<br>
              =C2=A0 =C2=A0 auto c3ptr =3D new C(C::default_buffer_size, 1,
              C::default_tries); =C2=A0// use the default buffer size but
              with a shorter timeout</div>
            <div>=C2=A0 =C2=A0 auto c4ptr =3D new C(2048, C::default_timeou=
t, 5);
              =C2=A0// testing: bump up the number of tries</div>
          </div>
          <div><br>
          </div>
          <div>I don't really want to make it <i>easier</i> for people
            to write the "function taking tons of defaulted parameters"
            antipattern.</div>
          <div>Let's teach people how to avoid the use of defaulted
            parameters, instead.</div>
          <div><br>
          </div>
          <div>=E2=80=93Arthur</div>
          <div><br>
          </div>
          <div><br>
          </div>
          On Monday, August 17, 2015 at 11:58:41 AM UTC-7, Bo Persson
          wrote:
          <blockquote class=3D"gmail_quote" style=3D"margin: 0;margin-left:
            0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;">On
            2015-08-17 20:37, Arthur Tchaikovsky wrote:
            <br>
            &gt; I would really appreciate some feedback from people, or
            is this proposal
            <br>
            &gt; so uninteresting that there is no point in wasting
            keyboard on it?
            <br>
            <br>
            You might wonder how widely used it will be?
            <br>
            <br>
            If not all parameters are of the same type, you can already
            get some of <br>
            the effect with a few overloads:
            <br>
            <br>
            =C2=A0 =C2=A0 =C2=A0void f(int a =3D 0, string b =3D "1",
            <br>
            =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 complex&lt;double&gt;=
 c =3D 2.0, type4 d =3D 3);
            <br>
            <br>
            =C2=A0 =C2=A0 =C2=A0inline void f(int a, complex&lt;double&gt; =
c)
            <br>
            =C2=A0 =C2=A0 =C2=A0{ f(a, "1", c, 3); }
            <br>
            <br>
            =C2=A0 =C2=A0 =C2=A0inline void f(string b, complex&lt;double&g=
t; c)
            <br>
            =C2=A0 =C2=A0 =C2=A0{ f(0, b, c, 3); }
            <br>
            <br>
            assuming that d is put last because you hardly ever want to
            change the <br>
            default.
            <br>
            <br>
            Just saying that you can already do this without a language
            change.
            <br>
            <br>
            <br>
            =C2=A0 =C2=A0 Bo Persson
            <br>
            <br>
            <br>
            <br>
            &gt;
            <br>
            &gt; On Saturday, 15 August 2015 17:49:50 UTC+1, Arthur
            Tchaikovsky wrote:
            <br>
            &gt;
            <br>
            &gt; =C2=A0 =C2=A0 Hi,
            <br>
            &gt; =C2=A0 =C2=A0 Does anyone see helpfulness of such solution=
:
            <br>
            &gt; =C2=A0 =C2=A0 Having fnc:
            <br>
            &gt;
            <br>
            &gt; =C2=A0 =C2=A0 void f(int a =3D 0, int b =3D 1, int c =3D 2=
, int d =3D 3);
            <br>
            &gt;
            <br>
            &gt; =C2=A0 =C2=A0 I think that it would be nice to be able to =
say
            whilst calling it
            <br>
            &gt; =C2=A0 =C2=A0 and requiring only some of those args to be
            non-default:
            <br>
            &gt;
            <br>
            &gt; =C2=A0 =C2=A0 f(default,2,default,4);
            <br>
            &gt;
            <br>
            &gt; =C2=A0 =C2=A0 Thoughts?
            <br>
            &gt;
            <br>
            &gt;
            <br>
            <br>
            <br>
          </blockquote>
        </div>
      </div>
      -- <br>
      <br>
      --- <br>
      You received this message because you are subscribed to the Google
      Groups "ISO C++ Standard - Future Proposals" group.<br>
      To unsubscribe from this group and stop receiving emails from it,
      send an email to <a moz-do-not-send=3D"true"
        href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposals+=
unsubscribe@isocpp.org</a>.<br>
      To post to this group, send email to <a moz-do-not-send=3D"true"
        href=3D"mailto:std-proposals@isocpp.org">std-proposals@isocpp.org</=
a>.<br>
      Visit this group at <a moz-do-not-send=3D"true"
        href=3D"http://groups.google.com/a/isocpp.org/group/std-proposals/"=
>http://groups.google.com/a/isocpp.org/group/std-proposals/</a>.<br>
    </blockquote>
    <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 />

--------------010403090403020403070202--

.
