220 41140 <20181130020338.GA2787@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: Fri, 30 Nov 2018 03:03:38 +0100
Lines: 90
Approved: news@gmane.org
Message-ID: <20181130020338.GA2787@noemi.bahnhof.se>
References: <CAB+4KHLe6zDPRreF2q0zQptUgrO0-_u8VrAOA7Du+_KHxhGUnw@mail.gmail.com>
 <20181129060523.GA21632@noemi.bahnhof.se>
 <CAB+4KHLNKgefS3mn+trH1_Yb1QBi-+8VvdHNos57g1a_8hJ6KQ@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 1543543297 22216 195.159.176.226 (30 Nov 2018 02:01:37 GMT)
X-Complaints-To: usenet@blaine.gmane.org
NNTP-Posting-Date: Fri, 30 Nov 2018 02:01:37 +0000 (UTC)
User-Agent: Mutt/1.10.1 (2018-07-13)
To: std-proposals@isocpp.org
Original-X-From: std-proposals+bncBDELLREETMBRB7VUQLQAKGQEED2KA7A@isocpp.org Fri Nov 30 03:01:33 2018
Return-path: <std-proposals+bncBDELLREETMBRB7VUQLQAKGQEED2KA7A@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-yb1-f200.google.com ([209.85.219.200])
	by blaine.gmane.org with esmtp (Exim 4.84_2)
	(envelope-from <std-proposals+bncBDELLREETMBRB7VUQLQAKGQEED2KA7A@isocpp.org>)
	id 1gSY7Y-0005eu-VA
	for gclcip-std-proposals@m.gmane.org; Fri, 30 Nov 2018 03:01:33 +0100
Original-Received: by mail-yb1-f200.google.com with SMTP id n195-v6sf2660450yba.5
        for <gclcip-std-proposals@m.gmane.org>; Thu, 29 Nov 2018 18:03:43 -0800 (PST)
ARC-Seal: i=2; a=rsa-sha256; t=1543543423; cv=pass;
        d=google.com; s=arc-20160816;
        b=rfi6zAAkc8dogubvA5AnUr8I5i5Ef8u+mVS53LbnpyEz0oIfWCuNKWbVC44J8XrRkI
         jc8Ono1h6d679JWu9Ak5lnri6Ow96LIR4hWCCcsA8d9kxg6v3kLP4gDPDgu8I2tdRemQ
         mB1cc+BXhtleqGzOQSEBt5oODpd2fd/rZ/qAoZkZhH8nmmnzp2DkyLUeAyt12dTs1SK6
         ltdEYq8X1r1AADE/8wncdUFF2C3wG1Jw63UnpGFW/2tikw4FdZmqW9eMG2QNYGWlLwbe
         2b/7WCR6wEoNUTeTNt8L7Ni1wG+Nz1V1mS0tjxpw4WkMZmXkMJV6b6owCSwculU0GFn2
         qFFw==
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=AJxPnqZtJ45pvAKug/IztcVhO6EwMd4SiX6PLjSf0H0=;
        b=qUPJQznVKMH94nvrVcJaMOB72eLN8782d/cfPG5PQFi757F0jgMctcZYR5Kmbax924
         ChihzGzHDHQmp7+8ntC5I13JFkCAkDLeWxGYlV+4cPK7snboi34g/gJ5bw///s+JCTyL
         TeLRkJBQQ69OCYr5hWxQhSXyj/UDHT4TIXs9EUrX3GA8b2hhe5tGtPbAtrFb6GREWmV5
         B2G71dHh5PfWvQr6Rr3hYJprqg+OceVPYUyNPpDduN+A9Ofe7QZjzOGvtb5PPn5SNPJQ
         FmIc9T0or4Mq5xskOmHTWm3UixSRmDZg2Ao0Y1Qie68zvkvANeDxo3JG4Nh0x49IJf4g
         hifA==
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=AJxPnqZtJ45pvAKug/IztcVhO6EwMd4SiX6PLjSf0H0=;
        b=kVLby4d9mvgfJ0wNu79Rmatc0f6SPGyoWUSZE6UOJhf3xfMKNZY4UZOd/M94XEDZrz
         k9WFL3EFSYfxMjXVTjp6y+wyeABkBIX7VwtCB+lbIpYFHZsdQE6Pku7BKsZ0QTjQHdwB
         YpnFgG99b/fGwXio5rR8QsHcY1JyuK4Z5eMmdMAs2wWXnqA/rpbmPqQxCTl8Pai6375p
         9tAObvN2pI7fyX+PNEOdFOSj76gusSaZcqqCTZQ09aezQy8aeG4ykdXGfDjJ/4IUdQxD
         90y5TaEHAre/u692/15GZQiQVObBPBjPgLbhrea+gaOtvN6JYKo+8hG2FIgO16kJX4RH
         YyRg==
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=AJxPnqZtJ45pvAKug/IztcVhO6EwMd4SiX6PLjSf0H0=;
        b=aNeEYudU19Cxeq1F5KNRCpwDjP1QNr666RHSowbNpTNQU1E49sDv8x4WExd9SGcWZo
         pD10qPGzLkT+pguTV0w71mwaVOn0RKlIoGJjnktDdz7SRBg+BIUvAFhaLx00VGIwufqf
         fQr0fdhPIKciEoFbqqe+arRrOVKDQizgEWo7T+nrtCvdb6IcmmPr38tAMJU+LZeXmECs
         3FbYziLkrDVghmLQWkbFXOghSHyLAnZnLTHcH2Z4Eol6noKom9txyM6PS2X9smLrYSby
         zSw9GtqhY5iUZCqTxfmGsZOIRroZM96Rw8BM6Zq7aKekWxuYCyzdON2uBfg 
X-Gm-Message-State: AA+aEWbVm48sM48b8zzVuk7QMq+KcD/WS803qr79FUozC/UvpGxnJri9
	yLlnJN7+iBAK0a6LVJkNTc8HhQ==
X-Google-Smtp-Source: AFSGD/XTekwjlZfLKKOZ2xMPdVnp5aIBW88IMMRkPqDTE9KLgfbUOGZhRTkrUm8gazQ9V5mvZcRliQ==
X-Received: by 2002:a5b:441:: with SMTP id s1-v6mr2406767ybp.80.1543543422965;
        Thu, 29 Nov 2018 18:03:42 -0800 (PST)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 2002:a25:3888:: with SMTP id f130-v6ls1884663yba.15.gmail; Thu,
 29 Nov 2018 18:03:41 -0800 (PST)
X-Received: by 2002:a25:a1c9:: with SMTP id a67-v6mr4122881ybi.64.1543543421939;
        Thu, 29 Nov 2018 18:03:41 -0800 (PST)
ARC-Seal: i=1; a=rsa-sha256; t=1543543421; cv=none;
        d=google.com; s=arc-20160816;
        b=A4KNA0zzPOfP7ihwsq1x6QUTlaXxE0I2kg1nCC0l2whroSY1qal7mp3MD8XlpfAg0M
         4O8Rc+bwtJQcHAndhu+7Z4bUU28dAdZ8wmaUZ/H39jQxoqhr6pYc+As9U0uUJD+TssVK
         hJyLcZ7MjpZEEyxXro622DI2P5earORIOUQAunEBXGp6u40LCSL8kv6t0h+PxmozS47h
         5Klhv4OoU993ggII4FIIuF9R8RpFDMVnHF6Xg8HvF7NDz14UNJcbqE6Izp1+C/bMRfoN
         O5kapdpHifOYqzULQGgDn5tXCUGB3fmAOl2938FQJxpcQCL5J2Vzv77tIyHNh6i+L83B
         KNHQ==
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=Fe1Age/WDnAd3aDO9g9I0QWW2nzhEsvVrcShYEz/umI=;
        b=ZQIrS95ZFW2p1S91jQ4fD16PIPw7Lgk1LjggXRC7VdmbfUQMh6PyDOXYhO4f1RZhBm
         3WbQ5o6Kfws6l7nfd5OKQxy1bIA5HkQaQEzaPFJBrUyodGCfn8JklRGlN3LbZD4ONxj6
         rm7PryMKE+I9GHFEfBpoMS01bpT5XsHslu5O5LPqJaU1syS1X1h8DTxjDXsvHx+qHUrX
         nibZJIjrSP7gQAmgWyBUBZ7pRDaye/QR/MQY1VfxqjJ6rr/1lkKPwv84QktFK6oAS/Po
         cuvSF1bi/2UA5BYLz6lpDFJ0hu6WlycLm6nFZevz046f7BQp0Zih/cacQSSq6gM3noXE
         a6Tg==
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 k6-v6si2534536ywg.46.2018.11.29.18.03.41
        for <std-proposals@isocpp.org>
        (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256);
        Thu, 29 Nov 2018 18:03:41 -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 E54524000B
	for <std-proposals@isocpp.org>; Fri, 30 Nov 2018 03:03:39 +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 AED2240007
	for <std-proposals@isocpp.org>; Fri, 30 Nov 2018 03:03:39 +0100 (CET)
Mail-Followup-To: std-proposals@isocpp.org
Content-Disposition: inline
In-Reply-To: <CAB+4KHLNKgefS3mn+trH1_Yb1QBi-+8VvdHNos57g1a_8hJ6KQ@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:41140
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/41140>

On Thu, Nov 29, 2018 at 04:19:25PM +1000, Andrew Tomazos wrote:
> On Thu, Nov 29, 2018 at 4:05 PM Magnus Fromreide <magfr@lysator.liu.se>
> wrote:
> 
> > 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
> 
> 
> To which benefits do you refer?
> 
> 
> > 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++.
> >
> 
> $ cat > t.cc
> void f(struct {}) {}
> $ g++ t.cc
> error: types may not be defined in parameter types
>  void f(struct {}) {}
> 
> Does this work in VC++?  Whats the gcc extension called?

The parts are independent, the first part is about allowing anonymous structs
in places where structs are allowed today.

> 
> > 2. Implicitly assume that a call to a function wants to call a function
> > named
> >    thus
> 
> 
> I don't quite follow sorry.  My proposal doesn't make any changes to name
> lookup of a function call or overload resolution, what changes to overload
> resolution are you proposing?

Consider

void f(struct { int a = 0; int b; });
void f(struct { int b; int c = 0; });

Which one should each of the following call?

f({a: 1, b: 2 }):
f({b: 1, c: 2 });
f({b: 1});

> 
> > 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.
> 
> And what is the right thing?  I'm not sure I see how this is related?

Look up types in the argument lsts  of the possible functions.

I will readily admit that I have failed to convey the idea here.

/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/20181130020338.GA2787%40noemi.bahnhof.se.

.
