220 41121 <20181129060523.GA21632@noemi.bahnhof.se> article
Path: news.gmane.org!.POSTED!not-for-mail
From: Magnus Fromreide <magfr@lysator.liu.se>
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Re: Function Parameter of Struct Type -> Named Parameters
Date: Thu, 29 Nov 2018 07:05:23 +0100
Lines: 39
Approved: news@gmane.org
Message-ID: <20181129060523.GA21632@noemi.bahnhof.se>
References: <CAB+4KHLe6zDPRreF2q0zQptUgrO0-_u8VrAOA7Du+_KHxhGUnw@mail.gmail.com>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: blaine.gmane.org
Mime-Version: 1.0
Content-Type: text/plain; charset="UTF-8"
X-Trace: blaine.gmane.org 1543471403 28166 195.159.176.226 (29 Nov 2018 06:03:23 GMT)
X-Complaints-To: usenet@blaine.gmane.org
NNTP-Posting-Date: Thu, 29 Nov 2018 06:03:23 +0000 (UTC)
User-Agent: Mutt/1.10.1 (2018-07-13)
To: std-proposals@isocpp.org
Original-X-From: std-proposals+bncBDELLREETMBRBJ4D73PQKGQE75MFDQA@isocpp.org Thu Nov 29 07:03:19 2018
Return-path: <std-proposals+bncBDELLREETMBRBJ4D73PQKGQE75MFDQA@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-yw1-f69.google.com ([209.85.161.69])
	by blaine.gmane.org with esmtp (Exim 4.84_2)
	(envelope-from <std-proposals+bncBDELLREETMBRBJ4D73PQKGQE75MFDQA@isocpp.org>)
	id 1gSFPz-0007DZ-7k
	for gclcip-std-proposals@m.gmane.org; Thu, 29 Nov 2018 07:03:19 +0100
Original-Received: by mail-yw1-f69.google.com with SMTP id q3-v6sf607636ywh.17
        for <gclcip-std-proposals@m.gmane.org>; Wed, 28 Nov 2018 22:05:30 -0800 (PST)
ARC-Seal: i=2; a=rsa-sha256; t=1543471529; cv=pass;
        d=google.com; s=arc-20160816;
        b=v36iVvKG9QP3XbQ4hfyvBWYmytw3zgzGkoj7U7g2IxcFxzER4hVJLp4jnqDEkClqCs
         95KNI2yq4xpAArzeqq0kpXxFymDgdYTTpTwMqJ4UtUuVs7EZcbua32lj6VFKfMAsPGCY
         MjiCUsD8ryWyxh/ezMbkXnlNsdFzpd4mQ8zumuRRNyT0Nakmiy/YyuUDU2J0plW0P1bH
         7zzLN2MwoaIRzz55EzD9Ycprfr1KkzJ8Ut30r/HP261rLU2xps/f3JdaJdO07w8XepqW
         P5/S03K+94NlmKqvsbqoWGr8OjFpdLs28surdQvZ/l+MvrWuX1u+4+/zsJdzBYVMJcrs
         HdjA==
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:user-agent:in-reply-to
         :content-disposition:mime-version:references:mail-followup-to
         :message-id:subject:to:from:date:dkim-signature;
        bh=aX+pIE++NXhJ0exBp3KHObfP5Z1rQMAfskuStXgzdqQ=;
        b=nv22huk2XejhngwXq+4k/kxVwwvWRMc9sqEHq6O/zNwUNxf1eyhoi6pK++s7mfFd1D
         Gdu/yWA2gFrL/rUL6Z8epge565pXUngvM0k/RKLcYrkpfot35pxFgNLsV5UWO2+5qyQh
         XotLuS/8n9ypeD3UJOoCrHZydiW7XVuT5s8qqL2xQ923BLaEOYQfwAEQ7M9Q44nmBarw
         fgucbcnJyOOvLPuCBoAsP9JcwwxH9u6mSassD0X6rR8pUMunB0fHpCVY54iMv8QVO59J
         HoiAGcthhB6I31vS+rPuZVztHqYTyNuVwyAaAfD1QfYgM4nMBK7DEujOVLiwZLAllN2h
         8jPQ==
ARC-Authentication-Results: i=2; mx.google.com;
       spf=pass (google.com: domain of magfr@lysator.liu.se designates 130.236.254.3 as permitted sender) smtp.mailfrom=magfr@lysator.liu.se;
       dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=liu.se
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=isocpp-org.20150623.gappssmtp.com; s=20150623;
        h=date:from:to:subject:message-id:mail-followup-to:references
         :mime-version:content-disposition:in-reply-to:user-agent
         :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=aX+pIE++NXhJ0exBp3KHObfP5Z1rQMAfskuStXgzdqQ=;
        b=XJ1H2siGlhQ5DMawTdl46PMSRRrXmoaYTqX4azOzPavCd6sK4GqHBRrZq8+Fcu8grQ
         Ml3i4JEizPjWsw2LPyjVKC9ukVXE+dPeVGHgeyk1wGfTx0uZMHxVBEjwIs4CieXRBlcW
         ej/Yas39pakM57jl3PRm1mJBUv/GkwwxTwO7XppIsnNpWMS6XYFU2OJbBf3a87fQ4F36
         ruIDZ1ydgpv5DxI1AAYGOX66Gp6fohbkSkoprKqXpRbFQf3gvJF7h7ORaWdkv228vWqg
         RYlFkSymUtaxO1vnhRaNXe31dxQIPzRjkDnYHumNbG33auc9JnC5/FQHme4BQQHhgpSD
         DrPw==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20161025;
        h=x-gm-message-state:date:from:to:subject:message-id:mail-followup-to
         :references:mime-version:content-disposition:in-reply-to:user-agent
         :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=aX+pIE++NXhJ0exBp3KHObfP5Z1rQMAfskuStXgzdqQ=;
        b=ABGyEcpVikLZATvcRhnAFbmJ6/A5kbsWtwowhhuI4FNkcraSSaL0otvJSp/ajTZzbH
         CkyJr0Bs4GJgIYbbX7QiCsuK0QV+dOhhvjCV/jhtUVVYNq9pIEE2ozSilL+O01Y1tyvF
         EFV4Mtt8XGCsEzw8zH6VeE/SBfDGRWQLrUROUV8v1Q4eCDQPcx26HBtx77D4ulp2QuOM
         46Ub1wme1C9vu7bGYxnebwZDkphSdl18YefMXpGkZHzebN9N9yy8a3YD26PUNzy6fhN2
         h0s6otp7XGZexTA+RFBMJiGVk0ovy2OqjXCnwoF1EVxOyYYPY3ttSAxiuTe 
X-Gm-Message-State: AA+aEWaC9WNkDG0q1ntP82ADS3L6HmilixxpooGBlGa+8RMqq3CP0Hho
	e61U83WS/AvyEGvgVi8UxW6K7Q==
X-Google-Smtp-Source: AFSGD/Vrr7k0y+d5cA1a9tNwR+Y5cWfsIq56/FZ9VisQEx6rMj/po7K7RXcyeFTeR2ka/DiX3GQX2w==
X-Received: by 2002:a81:238f:: with SMTP id j137mr95354ywj.24.1543471528639;
        Wed, 28 Nov 2018 22:05:28 -0800 (PST)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 2002:a81:a082:: with SMTP id x124ls297541ywg.1.gmail; Wed, 28 Nov
 2018 22:05:27 -0800 (PST)
X-Received: by 2002:a81:a9ca:: with SMTP id g193mr179082ywh.52.1543471527521;
        Wed, 28 Nov 2018 22:05:27 -0800 (PST)
ARC-Seal: i=1; a=rsa-sha256; t=1543471527; cv=none;
        d=google.com; s=arc-20160816;
        b=umCwchyPHVZgjOedyKvw1wWCm+guBIWUHzZdhRLbUmpMMQsL/+eVoZ5P250fsmIuRE
         M1PUBin9kw6muxeRoyd2I4lwpO9R2Rf0hmWBbE+rjbT0sQDhQE3fRIkYy2VhC/VKzlLO
         e6WM+ZPOUcNOtd+gL8qU8DKXdMxclo+DhoBC2F5got+tO576tbpFgm8qsMFTlVyJFwSo
         8/ka1B10fYF4QookmSi757X17Zx53sdneSngtmdybvATB/Jn9Wpjt7w9Ut2PovvgV8xL
         lpUqVgTW1OtAMj1OMKu4SKFQ8dAnrGsdwHB2ur6Uj1SSAz0RjJ5yi3prqMjTjHs1JUtE
         V4lQ==
ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816;
        h=user-agent:in-reply-to:content-disposition:mime-version:references
         :mail-followup-to:message-id:subject:to:from:date;
        bh=0a0X/Dl3pjTxh5uzBPhRZKLbto6AlhV7CAMG/PIbIsM=;
        b=SHNfnnrYkurnXJEQt/GukKChoZLrtysOyrY12anlmp+bGhOPP7lOoFA5uD6j3fjEjG
         5WDjUlWLeHhxj9C1pGfiS3+3gv8xTUk5LiwcybBNf734oe7+x3aiQzHkPKGemSXOIweV
         YQYT6NStnlEM31r1oQILqbuztsx+2rdqPxE4356Tq6KJQcyAhAh1X2/Sl3OhTr1QVDqV
         hXgJLPEVkmK5gNx2BsHo56knpX45zR4WNSrV/iZAENgjbzvNsB2HglvN8/qfLkuYRJFh
         blqGMllCa+Snk9rkhrj7rKKReX01ivNpkvE7yvjDQjVIu/NnrnOgMT6p47FWAbs62Oh5
         UEig==
ARC-Authentication-Results: i=1; mx.google.com;
       spf=pass (google.com: domain of magfr@lysator.liu.se designates 130.236.254.3 as permitted sender) smtp.mailfrom=magfr@lysator.liu.se;
       dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=liu.se
Original-Received: from mail.lysator.liu.se (mail.lysator.liu.se. [130.236.254.3])
        by mx.google.com with ESMTPS id u130si578520ywa.406.2018.11.28.22.05.27
        for <std-proposals@isocpp.org>
        (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256);
        Wed, 28 Nov 2018 22:05:27 -0800 (PST)
Received-SPF: pass (google.com: domain of magfr@lysator.liu.se designates 130.236.254.3 as permitted sender) client-ip=130.236.254.3;
Original-Received: from mail.lysator.liu.se (localhost [127.0.0.1])
	by mail.lysator.liu.se (Postfix) with ESMTP id EA2964000B
	for <std-proposals@isocpp.org>; Thu, 29 Nov 2018 07:05:24 +0100 (CET)
Original-Received: from noemi.bahnhof.se (h-155-4-131-135.NA.cust.bahnhof.se [155.4.131.135])
	(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
	(No client certificate requested)
	by mail.lysator.liu.se (Postfix) with ESMTPSA id C087C40007
	for <std-proposals@isocpp.org>; Thu, 29 Nov 2018 07:05:24 +0100 (CET)
Mail-Followup-To: std-proposals@isocpp.org
Content-Disposition: inline
In-Reply-To: <CAB+4KHLe6zDPRreF2q0zQptUgrO0-_u8VrAOA7Du+_KHxhGUnw@mail.gmail.com>
X-Virus-Scanned: ClamAV using ClamSMTP
X-Original-Sender: magfr@lysator.liu.se
X-Original-Authentication-Results: mx.google.com;       spf=pass (google.com:
 domain of magfr@lysator.liu.se designates 130.236.254.3 as permitted sender)
 smtp.mailfrom=magfr@lysator.liu.se;       dmarc=pass (p=NONE sp=NONE
 dis=NONE) header.from=liu.se
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:41121
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/41121>

On Thu, Nov 29, 2018 at 02:57:55PM +1000, Andrew Tomazos wrote:
> It seems to me that a function that takes a struct combined with C++20
> designated initializers gets us very close to named parameters:
> 
> struct FooParameters {
>     int bar;
>     float baz;
> };
> float foo(FooParameters params) {
>    return (params.bar + 3) * params.baz;
> }
> int main() {
>    foo({bar: 4, baz: 3.2});
> }
> 
> If we added some syntactic sugar that...
> 1. Removed the need to give the parameter struct type a name
> 2. Introduced the parameter struct members into the function definition
> scope.

I think this misses a lot of benefits and would propose two other rules:

1. Allow anonymous structs
   Similar to anonymous unions.
   This is already done by VC++ and as an extension by g++ and clang++.
2. Implicitly assume that a call to a function wants to call a function named
   thus and see if some overload could fit the provieded tokens, this would
   allow
   void fun(enum { something, other } x);
   to do the right thing as well.

/MF

-- 
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/20181129060523.GA21632%40noemi.bahnhof.se.

.
