220 27460 <CAOHCbivQ9cj=iMu9g1_AZha6Z27U=mDv+kdKxj=QqSw2Sp3zFw@mail.gmail.com> article
Path: news.gmane.org!.POSTED!not-for-mail
From: Tony V E <tvaneerd@gmail.com>
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Re: Proposal - non allocating std::function
Date: Mon, 1 Aug 2016 12:55:35 -0400
Lines: 171
Approved: news@gmane.org
Message-ID: <CAOHCbivQ9cj=iMu9g1_AZha6Z27U=mDv+kdKxj=QqSw2Sp3zFw@mail.gmail.com>
References: <e00db911-40f5-4c11-a4b8-32bba77aa0a5@isocpp.org>
 <CANh-dXnpUNf2O5NTj213K1Jfmhge1=eit6+SistzYWZj+5CkNg@mail.gmail.com>
 <ff1087cf-5777-47e9-8caa-d28136aae130@isocpp.org> <e725d932-5fbd-4ac9-b707-66ab6e02a413@isocpp.org>
 <CAGg_6+NEu8s5GVHQidjs8NPRkDwqGg2S3xDMseP41Y_jq77DVQ@mail.gmail.com>
 <d14a6548-9ddf-40c2-adc4-a046aff2d1e2@isocpp.org> <CAGg_6+MW9gAkGwgO03RZDj2=Fn0tb6zxKXui0+dbxVtG3WjyGQ@mail.gmail.com>
 <892618b7-19a9-4950-b552-ea5d5185362f@isocpp.org>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: blaine
Mime-Version: 1.0
Content-Type: multipart/alternative; boundary=001a114b703a20706005390578c0
X-Trace: blaine.gmane.org 1470070543 8875 195.159.176.226 (1 Aug 2016 16:55:43 GMT)
X-Complaints-To: usenet@blaine.gmane.org
NNTP-Posting-Date: Mon, 1 Aug 2016 16:55:43 +0000 (UTC)
To: Standard Proposals <std-proposals@isocpp.org>
Original-X-From: std-proposals+bncBCUZ5QWKNQIIT7X5XQCRUBF4EHIT4@isocpp.org Mon Aug 01 18:55:39 2016
Return-path: <std-proposals+bncBCUZ5QWKNQIIT7X5XQCRUBF4EHIT4@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-wm0-f69.google.com ([74.125.82.69])
	by blaine.gmane.org with esmtp (Exim 4.84_2)
	(envelope-from <std-proposals+bncBCUZ5QWKNQIIT7X5XQCRUBF4EHIT4@isocpp.org>)
	id 1bUGV8-00023z-Mp
	for gclcip-std-proposals@m.gmane.org; Mon, 01 Aug 2016 18:55:38 +0200
Original-Received: by mail-wm0-f69.google.com with SMTP id l4sf86095725wml.0
        for <gclcip-std-proposals@m.gmane.org>; Mon, 01 Aug 2016 09:55:39 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=isocpp-org.20150623.gappssmtp.com; s=20150623;
        h=mime-version:in-reply-to:references:from:date:message-id:subject:to
         :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=He6kQjHJL7cUnhZ7zi7OvBMEhZzLa5T3eqiiJrC+EBU=;
        b=ygGcSIqN1jN1UaWnW2+XFa4T3S14XS1atCRnK/PFmHlr+Rkrtt77tyEeKu+Mxw+Xfg
         lW1STQeUpVHIwX1bYULfnQcE+3vxTtMZwpMyt6NDU6KvF/BniU7ce49c5dhNVs0v98zd
         ma93LOAQYFojUWg0pRLa+QnofGZXqdBMMNGYSU4NV6UhEZTHNxCIHHgmzfNDwF0dHAuZ
         HaFk5xJakZq47jjktbF9nWYEMdcrYeEM6X0OrodcOKaCC6WXfRScnRoD9HBqIJOOsA7Y
         8HZTaImun5t5Lf7Xcb3P7aYzNkr5OzVD6lguonQGGwmfcPJYCvcrmjPcgaTII3bvKZM0
         vm/Q==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20130820;
        h=x-gm-message-state:mime-version:in-reply-to:references:from:date
         :message-id:subject:to: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=He6kQjHJL7cUnhZ7zi7OvBMEhZzLa5T3eqiiJrC+EBU=;
        b=ZfBzGoK3ZKCZNWOX7wk8L/y24F8D0GVuGO4Nx6Kq9lRmYDS0GHbAKrWUupDK6fZ72t
         l4+U+iM8y7zJQsYLhKW4GS1NK2h5ISIwsvar2ZreHpTEms8xjgnU61qMV17NwM4MeSQd
         b5tUpGE9zr4BOH6V7yo0KG1Syo+y7tWOoZLVwbv5alt0Z8nYBO6GhvPZCC7kzcHdLElK
         i3QnT0UW/i9aKiKWB1C3eN6afzHm+AXn6RmI1AYz3kwMq4SdgG8aaL4xySMr204hrt7U
         ekD4mWez8lqF5MGqMXwDnU3PrNJhDY7YmyuLkBSGkRizc1NPZmHRVHsjAVYVrfY3VpZG
         ge1w==
X-Gm-Message-State: AEkoouu7UbQ0XztIY7qe2AIc73+Wc2eDLMM1iAj4dQ4pB7SXiMk/PzvIM6iueIypvlxCPw==
X-Received: by 10.28.27.8 with SMTP id b8mr2143893wmb.0.1470070538051;
        Mon, 01 Aug 2016 09:55:38 -0700 (PDT)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.28.137.4 with SMTP id l4ls1934361wmd.26.gmail; Mon, 01 Aug
 2016 09:55:37 -0700 (PDT)
X-Received: by 10.28.127.209 with SMTP id a200mr54860956wmd.99.1470070537058;
        Mon, 01 Aug 2016 09:55:37 -0700 (PDT)
Original-Received: from mail-wm0-x232.google.com (mail-wm0-x232.google.com. [2a00:1450:400c:c09::232])
        by mx.google.com with ESMTPS id bf8si32315163wjb.121.2016.08.01.09.55.37
        for <std-proposals@isocpp.org>
        (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);
        Mon, 01 Aug 2016 09:55:37 -0700 (PDT)
Received-SPF: pass (google.com: domain of tvaneerd@gmail.com designates 2a00:1450:400c:c09::232 as permitted sender) client-ip=2a00:1450:400c:c09::232;
Original-Received: by mail-wm0-x232.google.com with SMTP id i5so253472814wmg.0
        for <std-proposals@isocpp.org>; Mon, 01 Aug 2016 09:55:37 -0700 (PDT)
X-Received: by 10.28.61.11 with SMTP id k11mr58762500wma.34.1470070536563;
 Mon, 01 Aug 2016 09:55:36 -0700 (PDT)
Original-Received: by 10.28.131.143 with HTTP; Mon, 1 Aug 2016 09:55:35 -0700 (PDT)
In-Reply-To: <892618b7-19a9-4950-b552-ea5d5185362f@isocpp.org>
X-Original-Sender: tvaneerd@gmail.com
X-Original-Authentication-Results: mx.google.com;       dkim=pass
 header.i=@gmail.com;       spf=pass (google.com: domain of tvaneerd@gmail.com
 designates 2a00:1450:400c:c09::232 as permitted sender) smtp.mailfrom=tvaneerd@gmail.com;
       dmarc=pass (p=NONE dis=NONE) header.from=gmail.com
Precedence: list
Mailing-list: list std-proposals@isocpp.org; contact std-proposals+owners@isocpp.org
List-ID: <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:27460
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/27460>

--001a114b703a20706005390578c0
Content-Type: text/plain; charset=UTF-8

On Sun, Jul 31, 2016 at 9:53 AM, Nicol Bolas <jmckesson@gmail.com> wrote:

>
>
> On Friday, July 15, 2016 at 3:13:58 AM UTC-4, Nevin ":-)" Liber wrote:
>>
>> On 14 July 2016 at 23:30, Nicol Bolas <jmck...@gmail.com> wrote:
>>
>>> The use case of "someone used `std::function` in an interface, but I use
>>> `std::inplace_function` internally, and I need to talk to their code."
>>> Right now, `std::function` is how lots of C++ code takes callbacks, and for
>>> good reason. But if I've wrapped some function in an `inplace_function`, I
>>> still need to be able to talk to them.
>>>
>>
>> Maybe std::function is the wrong vocabulary type for interfaces, just
>> like std::string is the wrong vocabulary type for interfaces, hence we will
>> have std::string_view.  Having something like llvm::function_ref that
>> Richard Smith described earlier might be a better fit (and LEWG might ask
>> Carl to add such a beast to his proposal).
>>
>
> That's a really good analogy. I think the principle concern for the user
> is this. `string_view` is a great interface type because you can use it to
> construct pretty much any kind of string you like. It isn't limited to just
> `std::string` construction.
>

I don't think that's why string_view is great.  Rather, string_view is
great because you probably don't need to create anything at all.  You
probably just need to *use* the characters, not keep them.  ie a
file_open(string_view) could (in theory at least) just use the characters
in the string_view to open the file, it doesn't need to create a string of
any kind to keep around. (unfortunately, in real life the OS probably needs
a null-terminated string).


> Would a hypothetical `function_view` have an interface that could be used
> to construct any kind of function wrapper? That is, how could it expose the
> actual type of the callable in such a way that someone could copy it out?
>
>
Same with function vs function_ref.  In most uses, you want to *call* the
function, not keep it or a copy of it.  Like sort(container, my_less).  You
want to call my_less, not keep it for later.

Tony


> Though we could probably get away with just allowing it to be converted to
> a `function`. Or rather more specifically, allowing `function` to be
> constructed from a `function_view`.
>
> --
> 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/892618b7-19a9-4950-b552-ea5d5185362f%40isocpp.org
> <https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/892618b7-19a9-4950-b552-ea5d5185362f%40isocpp.org?utm_medium=email&utm_source=footer>
> .
>



-- 
Be seeing you,
Tony

-- 
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/CAOHCbivQ9cj%3DiMu9g1_AZha6Z27U%3DmDv%2BkdKxj%3DQqSw2Sp3zFw%40mail.gmail.com.

--001a114b703a20706005390578c0
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><br><div class=3D"gmail_extra"><br><div class=3D"gmail_quo=
te">On Sun, Jul 31, 2016 at 9:53 AM, Nicol Bolas <span dir=3D"ltr">&lt;<a h=
ref=3D"mailto:jmckesson@gmail.com" target=3D"_blank">jmckesson@gmail.com</a=
>&gt;</span> wrote:<br><blockquote class=3D"gmail_quote" style=3D"margin:0 =
0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir=3D"ltr"><br>=
<br>On Friday, July 15, 2016 at 3:13:58 AM UTC-4, Nevin &quot;:-)&quot; Lib=
er wrote:<span class=3D""><blockquote class=3D"gmail_quote" style=3D"margin=
:0;margin-left:0.8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir=
=3D"ltr"><div>On 14 July 2016 at 23:30, Nicol Bolas <span dir=3D"ltr">&lt;<=
a rel=3D"nofollow">jmck...@gmail.com</a>&gt;</span> wrote:<br><div class=3D=
"gmail_quote"><blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;=
border-left:1px #ccc solid;padding-left:1ex"><div>The use case of &quot;som=
eone used `std::function` in an interface, but I use `std::inplace_function=
` internally, and I need to talk to their code.&quot; Right now, `std::func=
tion` is how lots of C++ code takes callbacks, and for good reason. But if =
I&#39;ve wrapped some function in an `inplace_function`, I still need to be=
 able to talk to them.<br></div></blockquote></div><br>Maybe std::function =
is the wrong vocabulary type for interfaces, just like std::string is the w=
rong vocabulary type for interfaces, hence we will have std::string_view.=
=C2=A0 Having something like llvm::function_ref that Richard Smith describe=
d earlier might be a better fit (and LEWG might ask Carl to add such a beas=
t to his proposal).<br></div></div></blockquote></span><div><br>That&#39;s =
a really good analogy. I think the principle concern for the user is this. =
`string_view` is a great interface type because you can use it to construct=
 pretty much any kind of string you like. It isn&#39;t limited to just `std=
::string` construction. </div></div></blockquote><div><br></div><div>I don&=
#39;t think that&#39;s why string_view is great.=C2=A0 Rather, string_view =
is great because you probably don&#39;t need to create anything at all.=C2=
=A0 You probably just need to *use* the characters, not keep them.=C2=A0 ie=
 a file_open(string_view) could (in theory at least) just use the character=
s in the string_view to open the file, it doesn&#39;t need to create a stri=
ng of any kind to keep around. (unfortunately, in real life the OS probably=
 needs a null-terminated string).<br>=C2=A0<br></div><blockquote class=3D"g=
mail_quote" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-l=
eft:1ex"><div dir=3D"ltr"><div>Would a hypothetical `function_view` have an=
 interface that could be used to construct any kind of function wrapper? Th=
at is, how could it expose the actual type of the callable in such a way th=
at someone could copy it out?<br><br></div></div></blockquote><div><br></di=
v><div>Same with function vs function_ref.=C2=A0 In most uses, you want to =
*call* the function, not keep it or a copy of it.=C2=A0 Like sort(container=
, my_less).=C2=A0 You want to call my_less, not keep it for later.<br><br><=
/div><div>Tony<br></div><div>=C2=A0<br></div><blockquote class=3D"gmail_quo=
te" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"=
><div dir=3D"ltr"><div>Though we could probably get away with just allowing=
 it to be converted to a `function`. Or rather more specifically, allowing =
`function` to be constructed from a `function_view`.<br></div></div><span c=
lass=3D"">

<p></p>

-- <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" target=3D"_=
blank">std-proposals+unsubscribe@isocpp.org</a>.<br>
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org" target=3D"_blank">std-proposals@isocpp.org</a>.<br></span>
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/892618b7-19a9-4950-b552-ea5d5185362f%=
40isocpp.org?utm_medium=3Demail&amp;utm_source=3Dfooter" target=3D"_blank">=
https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/892618b7-19a9-=
4950-b552-ea5d5185362f%40isocpp.org</a>.<br>
</blockquote></div><br><br clear=3D"all"><br>-- <br><div class=3D"gmail_sig=
nature" data-smartmail=3D"gmail_signature"><div dir=3D"ltr"><div>Be seeing =
you,<br></div>Tony<br></div></div>
</div></div>

<p></p>

-- <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 />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/CAOHCbivQ9cj%3DiMu9g1_AZha6Z27U%3DmDv=
%2BkdKxj%3DQqSw2Sp3zFw%40mail.gmail.com?utm_medium=3Demail&utm_source=3Dfoo=
ter">https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CAOHCbivQ=
9cj%3DiMu9g1_AZha6Z27U%3DmDv%2BkdKxj%3DQqSw2Sp3zFw%40mail.gmail.com</a>.<br=
 />

--001a114b703a20706005390578c0--

.
