220 28148 <6b360813-6dfd-484a-8258-3d3d1e41ca6e@isocpp.org> article
Path: news.gmane.org!.POSTED!not-for-mail
From: edward.catmur@mavensecurities.com
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Re: capturing monads in lambda
Date: Wed, 7 Sep 2016 15:00:27 -0700 (PDT)
Lines: 169
Approved: news@gmane.org
Message-ID: <6b360813-6dfd-484a-8258-3d3d1e41ca6e@isocpp.org>
References: <5dba8d2b-6689-4781-a95a-c94896d98e55@isocpp.org>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: blaine.gmane.org
Mime-Version: 1.0
Content-Type: multipart/alternative; 
	boundary="----=_Part_232_87301542.1473285627597"
X-Trace: blaine.gmane.org 1473285638 3699 195.159.176.226 (7 Sep 2016 22:00:38 GMT)
X-Complaints-To: usenet@blaine.gmane.org
NNTP-Posting-Date: Wed, 7 Sep 2016 22:00:38 +0000 (UTC)
Cc: szollosi.lorand@gmail.com
To: ISO C++ Standard - Future Proposals <std-proposals@isocpp.org>
Original-X-From: std-proposals+bncBDYODZPMTICBB7E3YK7AKGQEHII47JA@isocpp.org Thu Sep 08 00:00:34 2016
Return-path: <std-proposals+bncBDYODZPMTICBB7E3YK7AKGQEHII47JA@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-qk0-f199.google.com ([209.85.220.199])
	by blaine.gmane.org with esmtp (Exim 4.84_2)
	(envelope-from <std-proposals+bncBDYODZPMTICBB7E3YK7AKGQEHII47JA@isocpp.org>)
	id 1bhktT-0000DV-V8
	for gclcip-std-proposals@m.gmane.org; Thu, 08 Sep 2016 00:00:32 +0200
Original-Received: by mail-qk0-f199.google.com with SMTP id w204sf53158576qka.3
        for <gclcip-std-proposals@m.gmane.org>; Wed, 07 Sep 2016 15:00:33 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=isocpp-org.20150623.gappssmtp.com; s=20150623;
        h=date:from:to:cc:message-id:in-reply-to:references:subject
         :mime-version:x-original-sender:reply-to:precedence:mailing-list
         :list-id:x-spam-checked-in-group:list-post:list-help:list-archive
         :list-subscribe:list-unsubscribe;
        bh=3Uni+SUxOsSfMlE5I5wNaTUuFqbJJmlxlZLj1AaCbcQ=;
        b=hDvDH0I87tE4t37VnfrLLhDfXj6Q71ZMyYUk1EAv1kNRAoKnmEaocdrmiYdu/WmjeF
         4ZsDFBq5qXy/LSLzsO0Aj1Tqg1gN0PVpbwfPMjFO5LeG4VSVU9tAOoMDn1fam8RnLUH2
         MVE8S0SCcga8vNoiRhrPags0sPa3Ucb18HTFLItobHfgVHKW5MyoDwNaWu7jWSlcVxGf
         wWhYj+veK7MmEXH1FDuQz3JWk/eeiwx+cbWoD2t+J4iezMTLP7rMDHhI4UI7Jhlk4oCn
         lfpldKlqlpA3UhxgVsFfKXNikpc0yOYm1jli5IDm9CAI7fUiBUSlTkTvZjSwia5+vo2P
         tULw==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20130820;
        h=x-gm-message-state:date:from:to:cc:message-id:in-reply-to
         :references:subject:mime-version:x-original-sender:reply-to
         :precedence:mailing-list:list-id:x-spam-checked-in-group:list-post
         :list-help:list-archive:list-subscribe:list-unsubscribe;
        bh=3Uni+SUxOsSfMlE5I5wNaTUuFqbJJmlxlZLj1AaCbcQ=;
        b=OZ8wmtjr1Y7xDBPwm9Z5fXtG2DuODjT18fKY0sskUftr3pB1RzRbsPS1to/URabQ0W
         r5rByArBBtRjqzvB0un1pEJgNgOx1YvB7vHI+36ceCRSDQlPAkfA7h5rET9tMBN9UAd8
         cWv5HfVh20vA9VD0GNT+jbabVz1+3eLBlKU4kTeNzW3w3aN13kimt0wbFabmm8/Ox0xU
         nKRYl9CQe+L3Wcv69MM1wBzWEMibP/wBF4kkEe9E5dg9xmcVBA4SuKEWqXRlZAtgOMJT
         0H1dvH7OtOD6EM7NFgsHODMeJWkRSr1mjXkin/yP96BQ8kU17OnGbiIsQlduVyMKPFeg
         vv0w==
X-Gm-Message-State: AE9vXwNA91hm6Pjbd2YC/OQEmDhOGlnp/E+acqCVnpbZi+XbvRk3e1eAzlxGp7QlzkQw8Q==
X-Received: by 10.159.38.133 with SMTP id 5mr41139353uay.9.1473285633075;
        Wed, 07 Sep 2016 15:00:33 -0700 (PDT)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.36.214.81 with SMTP id o78ls1361243itg.22.gmail; Wed, 07 Sep
 2016 15:00:28 -0700 (PDT)
X-Received: by 10.36.39.214 with SMTP id g205mr238944ita.7.1473285628539;
        Wed, 07 Sep 2016 15:00:28 -0700 (PDT)
In-Reply-To: <5dba8d2b-6689-4781-a95a-c94896d98e55@isocpp.org>
X-Original-Sender: edward.catmur@mavensecurities.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:28148
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/28148>

------=_Part_232_87301542.1473285627597
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

On Wednesday, 7 September 2016 21:36:50 UTC+1, szollos...@gmail.com wrote:
>
> Hi,
>
> While thinking about for..else, I realized that it (and other language=20
> constructs) could be greatly simplified had we had the chance to capture=
=20
> monads created by keywords like return, continue, break. Before proposing=
=20
> any syntax/schematics, I'd first ask you, how would you feel about this=
=20
> generally. The idea is something like:
> [&return, break_=3D&break, break=3D...](){...}
>
> Capturing a monad assumes that it is valid to write it in the calling=20
> context.
>
> Note that capture is schematic, i.e., 'return' inside the lambda will=20
> destruct locals/parameters before performing caller's return; same holds=
=20
> for break and continue.
>

I'm assuming that a lambda capturing a control flow keyword has to have=20
return type void.

Still, what would this do?

int f() { auto&& l =3D [&return](int i){ return i; }; (l(5), puts("hello"))=
; }



--=20


This e-mail together with any attachments (the "Message") is confidential=
=20
and may contain privileged information. If you are not the intended=20
recipient or if you have received this e-mail in error, please notify the=
=20
sender immediately and permanently delete this Message from your system.=20
 Do not copy, disclose or distribute the information contained in this=20
Message.

=20

Maven Investment Partners Ltd (No. 07511928), Maven Derivatives Ltd (No.=20
07511840) , MVN Asset Management Limited (No. 09659116), Maven Europe Ltd=
=20
(No. 08966593) & Maven Securities Holding Ltd (No. 07505438) are registered=
=20
as companies in England and Wales and their registered address is Level 3,=
=20
6 Bevis Marks, London EC3A 7BA, United Kingdom. The companies=E2=80=99 VAT =
No. is=20
135539016. Only Maven Derivatives Ltd and MVN Asset Management Limited are=
=20
authorised by the Financial Conduct Authority (Maven Derivatives Ltd FRN:=
=20
607267, MVN Asset Management Limited FRN: 714429)

--=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.
To view this discussion on the web visit https://groups.google.com/a/isocpp=
..org/d/msgid/std-proposals/6b360813-6dfd-484a-8258-3d3d1e41ca6e%40isocpp.or=
g.

------=_Part_232_87301542.1473285627597
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">On Wednesday, 7 September 2016 21:36:50 UTC+1, szollos...@=
gmail.com  wrote:<blockquote class=3D"gmail_quote" style=3D"margin: 0;margi=
n-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><div dir=3D"l=
tr">Hi,<br><br>While thinking about for..else, I realized that it (and othe=
r language constructs) could be greatly simplified had we had the chance to=
 capture monads created by keywords like return, continue, break. Before pr=
oposing any syntax/schematics, I&#39;d first ask you, how would you feel ab=
out this generally. The idea is something like:<br>[&amp;return, break_=3D&=
amp;break, break=3D...](){...}<br><br>Capturing a monad assumes that it is =
valid to write it in the calling context.<br><br>Note that capture is schem=
atic, i.e., &#39;return&#39; inside the lambda will destruct locals/paramet=
ers before performing caller&#39;s return; same holds for break and continu=
e.<br></div></blockquote><div><br></div><div>I&#39;m assuming that a lambda=
 capturing a control flow keyword has to have return type void.</div><div><=
br></div><div>Still, what would this do?</div><div><br></div><div class=3D"=
prettyprint" style=3D"border: 1px solid rgb(187, 187, 187); word-wrap: brea=
k-word; background-color: rgb(250, 250, 250);"><code class=3D"prettyprint">=
<div class=3D"subprettyprint"><span style=3D"color: #008;" class=3D"styled-=
by-prettify">int</span><span style=3D"color: #000;" class=3D"styled-by-pret=
tify"> f</span><span style=3D"color: #660;" class=3D"styled-by-prettify">()=
</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><s=
pan style=3D"color: #660;" class=3D"styled-by-prettify">{</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color=
: #008;" class=3D"styled-by-prettify">auto</span><span style=3D"color: #660=
;" class=3D"styled-by-prettify">&amp;&amp;</span><span style=3D"color: #000=
;" class=3D"styled-by-prettify"> l </span><span style=3D"color: #660;" clas=
s=3D"styled-by-prettify">=3D</span><span style=3D"color: #000;" class=3D"st=
yled-by-prettify"> </span><span style=3D"color: #660;" class=3D"styled-by-p=
rettify">[&amp;</span><span style=3D"color: #008;" class=3D"styled-by-prett=
ify">return</span><span style=3D"color: #660;" class=3D"styled-by-prettify"=
>](</span><span style=3D"color: #008;" class=3D"styled-by-prettify">int</sp=
an><span style=3D"color: #000;" class=3D"styled-by-prettify"> i</span><span=
 style=3D"color: #660;" class=3D"styled-by-prettify">){</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color=
: #008;" class=3D"styled-by-prettify">return</span><span style=3D"color: #0=
00;" class=3D"styled-by-prettify"> i</span><span style=3D"color: #660;" cla=
ss=3D"styled-by-prettify">;</span><span style=3D"color: #000;" class=3D"sty=
led-by-prettify"> </span><span style=3D"color: #660;" class=3D"styled-by-pr=
ettify">};</span><span style=3D"color: #000;" class=3D"styled-by-prettify">=
 </span><span style=3D"color: #660;" class=3D"styled-by-prettify">(</span><=
span style=3D"color: #000;" class=3D"styled-by-prettify">l</span><span styl=
e=3D"color: #660;" class=3D"styled-by-prettify">(</span><span style=3D"colo=
r: #066;" class=3D"styled-by-prettify">5</span><span style=3D"color: #660;"=
 class=3D"styled-by-prettify">),</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"> puts</span><span style=3D"color: #660;" class=3D"s=
tyled-by-prettify">(</span><span style=3D"color: #080;" class=3D"styled-by-=
prettify">&quot;hello&quot;</span><span style=3D"color: #660;" class=3D"sty=
led-by-prettify">));</span><span style=3D"color: #000;" class=3D"styled-by-=
prettify"> </span><span style=3D"color: #660;" class=3D"styled-by-prettify"=
>}</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br></sp=
an></div></code></div><div><br><br></div></div>
<br>
<p><font color=3D"#222222" face=3D"Arial, sans-serif"><span style=3D"font-s=
ize:13px">This e-mail together with any attachments (the &quot;Message&quot=
;) is confidential and may contain privileged information. If you are not t=
he intended recipient or if you have received this e-mail in error, please =
notify the sender immediately and permanently delete this Message from your=
 system. =C2=A0Do not copy, disclose or distribute the information containe=
d in this Message.</span></font></p><p><font color=3D"#222222" face=3D"Aria=
l, sans-serif"><span style=3D"font-size:13px">=C2=A0</span></font></p><p><f=
ont color=3D"#222222" face=3D"Arial, sans-serif"><span style=3D"font-size:1=
3px">Maven Investment Partners Ltd (No. 07511928), Maven Derivatives Ltd (N=
o. 07511840) , MVN Asset Management Limited (No. 09659116), Maven Europe Lt=
d (No. 08966593) &amp; Maven Securities Holding Ltd (No. 07505438) are regi=
stered as companies in England and Wales and their registered address is Le=
vel 3, 6 Bevis Marks, London EC3A 7BA, United Kingdom. The companies=E2=80=
=99 VAT No. is 135539016. Only Maven Derivatives Ltd and MVN Asset Manageme=
nt Limited are authorised by the Financial Conduct Authority (Maven Derivat=
ives Ltd FRN: 607267, MVN Asset Management Limited FRN: 714429)</span></fon=
t></p>

<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/6b360813-6dfd-484a-8258-3d3d1e41ca6e%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/6b360813-6dfd-484a-8258-3d3d1e41ca6e=
%40isocpp.org</a>.<br />

------=_Part_232_87301542.1473285627597--

.
