220 40025 <60449422-b543-4949-557a-96435c1c2926@technion.ac.il> article
Path: news.gmane.org!.POSTED!not-for-mail
From: Eyal Rozenberg <eyalroz@technion.ac.il>
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Re: Re: Named Parameters for C++
Date: Sun, 26 Aug 2018 23:35:10 +0300
Lines: 48
Approved: news@gmane.org
Message-ID: <60449422-b543-4949-557a-96435c1c2926@technion.ac.il>
References: <CAPuuy5eBx1ybcPjS6dNsk7n1_c2uhdRBS19qr=q5cj3cTURnLQ@mail.gmail.com>
 <5d064165-5a58-4810-90f7-aa3732be92db@isocpp.org>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: blaine.gmane.org
Mime-Version: 1.0
Content-Type: text/plain; charset="UTF-8"; format=flowed
X-Trace: blaine.gmane.org 1535315599 26199 195.159.176.226 (26 Aug 2018 20:33:19 GMT)
X-Complaints-To: usenet@blaine.gmane.org
NNTP-Posting-Date: Sun, 26 Aug 2018 20:33:19 +0000 (UTC)
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101
 Thunderbird/52.9.1
To: std-proposals@isocpp.org, Nicol Bolas <jmckesson@gmail.com>
Original-X-From: std-proposals+bncBDHKZN7LR4ARBC46RTOAKGQESDJLZQQ@isocpp.org Sun Aug 26 22:33:15 2018
Return-path: <std-proposals+bncBDHKZN7LR4ARBC46RTOAKGQESDJLZQQ@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-ed1-f70.google.com ([209.85.208.70])
	by blaine.gmane.org with esmtp (Exim 4.84_2)
	(envelope-from <std-proposals+bncBDHKZN7LR4ARBC46RTOAKGQESDJLZQQ@isocpp.org>)
	id 1fu1ik-0006gq-J9
	for gclcip-std-proposals@m.gmane.org; Sun, 26 Aug 2018 22:33:14 +0200
Original-Received: by mail-ed1-f70.google.com with SMTP id h40-v6sf5810074edb.2
        for <gclcip-std-proposals@m.gmane.org>; Sun, 26 Aug 2018 13:35:24 -0700 (PDT)
ARC-Seal: i=2; a=rsa-sha256; t=1535315724; cv=pass;
        d=google.com; s=arc-20160816;
        b=mQe9f2m8TTFCJAMol8ic91A5LDfdxTRLcCb9LaonzWucBP2c7mNBzlS+syVKaeM5L7
         nt4Sx1U87Faq75nEeib+sBM4FVu6DDPGn7wU1e1XGJrq+tb6yVwXbmsGiDxTYa5GhvDu
         mype435NoY8Kh97GN6HWbmuMuyBB4bMbOsreXmrxskQAKNWI47290I6RiBLYN4jUwPz6
         eKisxKHOzClW54dmW1QgmFSnv/rrX08wCfBu+h3ja/Yrdvqxy6C29dHx7zgcxopDxqqv
         oCQ5TR8Dr93TvzNJQ6NXn2gT00BnPeEZBAAMg4hLpzwJGAvPrSB0zLMeNBzJXJkpuNGu
         xn1Q==
ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816;
        h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post
         :list-id:mailing-list:precedence:reply-to:content-language
         :in-reply-to:mime-version:user-agent:date:message-id:from:references
         :to:subject:arc-authentication-results:arc-message-signature
         :dkim-signature:arc-authentication-results;
        bh=Ehf/5Ib7kNg9skxUTIx/rRDEpo6fWWnWYOsOJCDDG3o=;
        b=wlf4Z45vXqLoBRRe9E97u4G1RyzNyajczwwP8PCrWt9L+0rNsf0m+gZbj16MvF73ii
         30fcBUbft9bMaSjblLnkHS3XWYfc9QYq6fgRUC+zHla3cL5vU9tyg55h9QiiGTjG7t4R
         WCbfMsEQMKRWfp2x2DmB0I4sfuWt1mNgHepMrBp9xtJmJEEc7Slekk6eZ7Bo7AbriWor
         VotmVaxA9pakhR/PcMo1wyMZMDMg/Lxf7xfb6sXlEWQ13Uj9mwGF2ruja8zqM/SUP6CQ
         c5SJhsaU6gVcOMpaLdSHo8oBK4nwhPrIbVKuXfREOGjFgeqeg70eYDinI3wLdbxF3EIc
         u3Og==
ARC-Authentication-Results: i=2; mx.google.com;
       spf=pass (google.com: domain of srs0=2jryg=lj=technion.ac.il=eyalroz@cwi.nl designates 192.16.191.27 as permitted sender) smtp.mailfrom="SRS0=2JRYg=LJ=technion.ac.il=eyalroz@cwi.nl";
       dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=technion.ac.il
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=isocpp-org.20150623.gappssmtp.com; s=20150623;
        h=subject:to:references:from:message-id:date:user-agent:mime-version
         :in-reply-to:content-language:x-original-sender
         :x-original-authentication-results:reply-to:precedence:mailing-list
         :list-id:list-post:list-help:list-archive:list-subscribe
         :list-unsubscribe;
        bh=Ehf/5Ib7kNg9skxUTIx/rRDEpo6fWWnWYOsOJCDDG3o=;
        b=qRoXuhrfYxs/oHDbJiDmJbvzDaWoyFswSgB7CCrWUuTi1txtEQ4UmvACTJWyO+PnaA
         hwTgXG3v45hs1fTPy3XZukks79IcvD24Uvwuy4lVi6PxqWqJ8xdBv/IzI3Y/ETBWU2qM
         WNPMgxFCCGF/4blUIN73oMG74wyL01feb48dS1bqBZcdaxa3V/sa7Vqb9UWUwesNhq0H
         DaX5Gkmcx5tJ0jQlo7pLKUTr4PEbUYEwYHu6gMR0la1IvOi38/c5ROeyMy2oOwds+rbr
         cwYWa3KQzXrwBWLkInAFMYrzUK4MALO1JMAQmNAH51Uhukj3BFuRAlp0TtYT7InGN0/s
         1TFQ==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20161025;
        h=x-gm-message-state:subject:to:references:from:message-id:date
         :user-agent:mime-version:in-reply-to:content-language
         :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=Ehf/5Ib7kNg9skxUTIx/rRDEpo6fWWnWYOsOJCDDG3o=;
        b=S8/hlWREFrbuBJgPgr26NtGCnsu8NSYACQICvz559jhtamZpv8jOaS7aBiNVUBZpFT
         vSoBdAWoVpe9tkAvlPdFRsiCQ9G6NqZI4PzYF7KE61hr52Eb1CoWdPofTjQe3VS9EMKI
         LLLGSUuBNToEyFFsM5a+JAnatRzYsPA8LSN/exoGjK1Ky2ChyVppb6SjeVEGX+7NlraX
         zRcAaqyEO2CqsuPHFI7wBFazX/Bs5BYsiqAdiGckuUMtDE2oOHqCA5FVcrdFddVDh++h
         fDJz0pKI8Z++HtC3vqLjWOh/0rf5uNWnf0dYRCGEbIQSFI1qjE9H5FGxWlM+zLxyelcT
         i 
X-Gm-Message-State: APzg51BqmxEARU51aKkAOo3zlIH1IdAXbxxCB9jWYf5N9p7rj2E8cxsK
	L9AgHbwYzNylHrkHt1kwp6I=
X-Google-Smtp-Source: ANB0VdYLm7/d1e6sXNnaWz09HUD9UcvwnVt2NSbl/+/t+CROX26nHlqIkLMmmy9emMdgA6ARpm52nQ==
X-Received: by 2002:a50:8bcd:: with SMTP id n13-v6mr2685942edn.0.1535315724728;
        Sun, 26 Aug 2018 13:35:24 -0700 (PDT)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 2002:a50:ed0c:: with SMTP id j12-v6ls6169496eds.4.gmail; Sun, 26
 Aug 2018 13:35:23 -0700 (PDT)
X-Received: by 2002:a50:a166:: with SMTP id 93-v6mr13507039edj.184.1535315723034;
        Sun, 26 Aug 2018 13:35:23 -0700 (PDT)
ARC-Seal: i=1; a=rsa-sha256; t=1535315723; cv=none;
        d=google.com; s=arc-20160816;
        b=S1AB9eYrpf2sC8yg391ncnNSlGV73s+49p5fWjj2t87/GZMpgnOK3kpDHECX6wTT6m
         UhY9EMb/jei7lFVmGjEH3qAiPjdOcvq2qUg6IlMBK5ZWIaJHDRW9tT9V5+c8m4I/pQCJ
         Jjk1gAL16Xr16WuEBjkOFA+JoUicvUGYspLTdiKgwqU46Y+wcoIrcDalCOmiVbOl6ucO
         9Xk2kXwJM5pXrEuf4gXrAKYwSjKz2OCU9w9kyLG96Df0w8eG2Yu4g20MmOGOB7Zbq+pA
         nFr+8yytL2zA4XPE9jX/LaIa/spDcGq+qBui9PXCZ0tNP8EVrXe+m0yUtRLGlx8wgs4R
         oAVg==
ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816;
        h=content-transfer-encoding:content-language:in-reply-to:mime-version
         :user-agent:date:message-id:from:references:to:subject
         :arc-authentication-results;
        bh=oczolUQl5M0ohk34UFgVynRr42qUOBLWuBbzbuWVI1s=;
        b=UzcfHLPTp+O4U0LSJYXEpE495g3Vlr/7271jFlZYNYs4dlBm6TAfiTMMIereeKqQVX
         f8BTX/cA8Yn6h6/mTSuVIG7ntFUfAzLQi4wNIQJS8d9sJUSd3hKoa8iRZweRzH3/rdgZ
         H4TvkRy8+oIUHyQMMietJYV6V2Ba6EPzPIpopD4Qmg5kX22ROAV2ZLLw8H5/2Bp9bzDE
         UlmvURsDQbuX1JweEdx7lKNUYoLVE7ROPNCCkOAUlKhErnBa6e63bs+A5LEb5yc9W/sc
         dSgYYoq65dfXwxoqLb5AAB3vyHD9/aKAqduFMwoKl1lK2iH0abhHkpmAuDkR02I+cxmq
         GhJA==
ARC-Authentication-Results: i=1; mx.google.com;
       spf=pass (google.com: domain of srs0=2jryg=lj=technion.ac.il=eyalroz@cwi.nl designates 192.16.191.27 as permitted sender) smtp.mailfrom="SRS0=2JRYg=LJ=technion.ac.il=eyalroz@cwi.nl";
       dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=technion.ac.il
Original-Received: from fester.cwi.nl (fester.cwi.nl. [192.16.191.27])
        by mx.google.com with ESMTPS id g25-v6si1380749edr.396.2018.08.26.13.35.22
        for <std-proposals@isocpp.org>
        (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);
        Sun, 26 Aug 2018 13:35:23 -0700 (PDT)
Received-SPF: pass (google.com: domain of srs0=2jryg=lj=technion.ac.il=eyalroz@cwi.nl designates 192.16.191.27 as permitted sender) client-ip=192.16.191.27;
Original-Received: from fester.cwi.nl (fester.cwi.nl [192.16.191.27])
	by fester.cwi.nl (8.14.4/8.12.3) with ESMTP id w7QKZN5t016821;
	Sun, 26 Aug 2018 22:35:23 +0200
Original-Received: from [192.168.0.83] ([87.69.233.180])
	(authenticated bits=0)
	by fester.cwi.nl (8.14.4/8.12.3) with ESMTP id w7QKZH2x016819
	(version=TLSv1/SSLv3 cipher=DHE-RSA-AES128-SHA bits=128 verify=NO);
	Sun, 26 Aug 2018 22:35:21 +0200
In-Reply-To: <5d064165-5a58-4810-90f7-aa3732be92db@isocpp.org>
Content-Language: en-US
X-Original-Sender: eyalroz@technion.ac.il
X-Original-Authentication-Results: mx.google.com;       spf=pass (google.com:
 domain of srs0=2jryg=lj=technion.ac.il=eyalroz@cwi.nl designates
 192.16.191.27 as permitted sender) smtp.mailfrom="SRS0=2JRYg=LJ=technion.ac.il=eyalroz@cwi.nl";
       dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=technion.ac.il
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: <https://groups.google.com/a/isocpp.org/group/std-proposals/post>, <mailto:std-proposals@isocpp.org>
List-Help: <https://support.google.com/a/isocpp.org/bin/topic.py?topic=25838>, <mailto:std-proposals+help@isocpp.org>
List-Archive: <https://groups.google.com/a/isocpp.org/group/std-proposals/>
List-Subscribe: <https://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>,
 <https://groups.google.com/a/isocpp.org/group/std-proposals/subscribe>
Xref: news.gmane.org gmane.comp.lang.c++.isocpp.proposals:40025
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/40025>

Given your described use of designated initializers, how would you feel 
about something like following proposal:

1. Functions with named parameter support must be marked with a 
[[named-param]] attribute.
2. Such marked functions get an anonymous struct defined for their 
parameters, just like FooParams in your example, and what actually gets 
compiled is

void foo(int, int);
void foo(_some_autogenerated_foo_params_struct_identifier);

3. Tie thing up syntax-wise so that you can write foo(.x = 5, .y = 12), 
and also have some sort of syntactic solution for using &foo .


Not that I had a dog in this fight, I'm just trying to help map out some 
possibilities.


On 16/08/18 18:42, Nicol Bolas wrote:
> This even works through forwarding, but it does require you to 
> explicitly name the `FoosParams` type at the call site:
> 
> std::function<void(FoosParams)> foofunctor = &foo;
> foofunctor(FoosParams{.x = 5, .y = 12});
> 
> Now of course, this way of handling named parameters causes a bunch of 
> warts. Anytime you want to create such a function, you have to 
> explicitly create a type for it. Forwarding, or any usage of the 
> signature, requires using that typename. And while you can forward them, 
> the forwarding function only sees it as a single struct, not a set of 
> values. This makes doing things like transforming parameters impossible 
> (well, without reflection, and even then, your code would have to assume 
> that the single struct is a set of "parameters" to be transformed). And 
> so forth.
> 
> But overall, it gets the job done without language changes. It's not 
> clean, so it won't be used universally or anything, but it works well 
> enough that it can be used in places where the ambiguity of a call is 
> worse than having to pass a struct

-- 
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.
To post to this group, send email to std-proposals@isocpp.org.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/60449422-b543-4949-557a-96435c1c2926%40technion.ac.il.

.
