220 4599 <CAFk2RUax65FEaDaeKCEdBig+bq4W4u_+39R3hsdBuyiOj-rpjA@mail.gmail.com> article
Path: news.gmane.org!not-for-mail
From: Ville Voutilainen <ville.voutilainen@gmail.com>
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Re: Changing lambda scope
Date: Sun, 26 May 2013 17:39:57 +0300
Lines: 115
Approved: news@gmane.org
Message-ID: <CAFk2RUax65FEaDaeKCEdBig+bq4W4u_+39R3hsdBuyiOj-rpjA@mail.gmail.com>
References: <ae01f736-d3ac-48d6-981f-702b9ab2b3b3@isocpp.org>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: plane.gmane.org
Mime-Version: 1.0
Content-Type: multipart/alternative; boundary=90e6ba308f8290f13404dda00173
X-Trace: ger.gmane.org 1369579202 28148 80.91.229.3 (26 May 2013 14:40:02 GMT)
X-Complaints-To: usenet@ger.gmane.org
NNTP-Posting-Date: Sun, 26 May 2013 14:40:02 +0000 (UTC)
To: std-proposals@isocpp.org
Original-X-From: std-proposals+bncBC5JHI7A7ALRBPV5RCGQKGQEVWJNSGQ@isocpp.org Sun May 26 16:40:02 2013
Return-path: <std-proposals+bncBC5JHI7A7ALRBPV5RCGQKGQEVWJNSGQ@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-vc0-f199.google.com ([209.85.220.199])
	by plane.gmane.org with esmtp (Exim 4.69)
	(envelope-from <std-proposals+bncBC5JHI7A7ALRBPV5RCGQKGQEVWJNSGQ@isocpp.org>)
	id 1Ugc75-0000A0-Kr
	for gclcip-std-proposals@m.gmane.org; Sun, 26 May 2013 16:39:59 +0200
Original-Received: by mail-vc0-f199.google.com with SMTP id hf12sf7824492vcb.6
        for <gclcip-std-proposals@m.gmane.org>; Sun, 26 May 2013 07:39:58 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=20120113;
        h=x-beenthere:mime-version:in-reply-to:references:date:message-id
         :subject:from:to:x-original-sender:x-original-authentication-results
         :reply-to:precedence:mailing-list:list-id:x-google-group-id
         :list-post:list-help:list-archive:list-subscribe:list-unsubscribe
         :content-type;
        bh=qW31wlbb/EwuTbNKLkqBhBmlvc9gq/0+07CJR8YqY4I=;
        b=aTv3KYIJULsEQcbYgcFHPcOk7btyjypZ2S6FA4AW+Fcn0HgxYnx3HvKTyY11dL1B3t
         uN2cEiGcUdPLLVnutTi7lUgjvA4YEx7Q7Pmlnuaujpx37FSDOJiXdhtkCc60/WjYNOtj
         IoPtwkHbRZ/MGEVsVc/aFTd6qjM0wO2OFnYC+ESXHVItiNpESNGWbWK6JqVlb5rsERj7
         LL+1touJ5i8xF4wKVkoq5ktZ4LF9Ju/HwF367q+z6pR6iCU0Xmfnrr2daW4+SgDKxn2b
         ZLsmBg2M8xF93bZMBE7t4UHo1FmT6mgOF+t3WskUD3JwOb+UCs7gIsZQ+7s4ZLIOH/Fn
         VPOA==
X-Received: by 10.236.41.137 with SMTP id h9mr13018905yhb.43.1369579198676;
        Sun, 26 May 2013 07:39:58 -0700 (PDT)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.49.129.36 with SMTP id nt4ls2553137qeb.25.gmail; Sun, 26 May
 2013 07:39:57 -0700 (PDT)
X-Received: by 10.49.0.244 with SMTP id 20mr27930538qeh.50.1369579197755;
        Sun, 26 May 2013 07:39:57 -0700 (PDT)
Original-Received: from mail-qc0-x233.google.com (mail-qc0-x233.google.com [2607:f8b0:400d:c01::233])
        by mx.google.com with ESMTPS id ed5si9204341qcb.32.2013.05.26.07.39.57
        for <std-proposals@isocpp.org>
        (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128);
        Sun, 26 May 2013 07:39:57 -0700 (PDT)
Received-SPF: pass (google.com: domain of ville.voutilainen@gmail.com designates 2607:f8b0:400d:c01::233 as permitted sender) client-ip=2607:f8b0:400d:c01::233;
Original-Received: by mail-qc0-f179.google.com with SMTP id e1so3189362qcx.10
        for <std-proposals@isocpp.org>; Sun, 26 May 2013 07:39:57 -0700 (PDT)
X-Received: by 10.229.0.141 with SMTP id 13mr9310716qcb.80.1369579197611; Sun,
 26 May 2013 07:39:57 -0700 (PDT)
Original-Received: by 10.224.174.143 with HTTP; Sun, 26 May 2013 07:39:57 -0700 (PDT)
In-Reply-To: <ae01f736-d3ac-48d6-981f-702b9ab2b3b3@isocpp.org>
X-Original-Sender: ville.voutilainen@gmail.com
X-Original-Authentication-Results: mx.google.com;       spf=pass (google.com:
 domain of ville.voutilainen@gmail.com designates 2607:f8b0:400d:c01::233 as
 permitted sender) smtp.mail=ville.voutilainen@gmail.com;       dkim=pass header.i=@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: <http://groups.google.com/a/isocpp.org/group/std-proposals/post?hl=en>,
 <mailto:std-proposals@isocpp.org>
List-Help: <http://support.google.com/a/isocpp.org/bin/topic.py?hl=en&topic=25838>,
 <mailto:std-proposals+help@isocpp.org>
List-Archive: <http://groups.google.com/a/isocpp.org/group/std-proposals/?hl=en>
List-Subscribe: <http://groups.google.com/a/isocpp.org/group/std-proposals/subscribe?hl=en>,
 <mailto:std-proposals+subscribe@isocpp.org>
List-Unsubscribe: <http://groups.google.com/a/isocpp.org/group/std-proposals/subscribe?hl=en>,
 <mailto:googlegroups-manage+399137483710+unsubscribe@googlegroups.com>
Xref: news.gmane.org gmane.comp.lang.c++.isocpp.proposals:4599
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/4599>

--90e6ba308f8290f13404dda00173
Content-Type: text/plain; charset=ISO-8859-1

On 26 May 2013 16:59, DeadMG <wolfeinstein@gmail.com> wrote:

> Pursuant to a recent discussion, I have discovered that lambdas are a
> local class to whatever scope they are nested in. This means that ADL can't
> find operators for them. For example,
>
> namespace X {
>     template<typename L, typename R> L operator+(L l, R r) {
>         //...
>     }
>     auto f() {
>         return [] {};
>     }
> };
> int main() {
>     1 + X::f(); // Fail
> }
>
> I propose that the wording be changed so that lambdas' associated
> namespace should be the most nested namespace containing whatever scope
> they are declared in. Having operators available to work on lambdas
> considerably simplifies certain functional APIs, as you can just return a
> lambda directly. However, the current wording would require using
> hand-created types purely for the purpose of ADL.
>

Seems.. ..reasonable, I guess. I have trouble imagining when I would want
to use such a feature, so if you could
provide a bit more complete example, that would be nice.

-- 

--- 
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.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposals/?hl=en.



--90e6ba308f8290f13404dda00173
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><br><div class=3D"gmail_extra"><br><br><div class=3D"gmail=
_quote">On 26 May 2013 16:59, DeadMG <span dir=3D"ltr">&lt;<a href=3D"mailt=
o:wolfeinstein@gmail.com" target=3D"_blank">wolfeinstein@gmail.com</a>&gt;<=
/span> wrote:<br>
<blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1p=
x #ccc solid;padding-left:1ex">Pursuant to a recent discussion, I have disc=
overed that lambdas are a local class to whatever scope they are nested in.=
 This means that ADL can&#39;t find operators for them. For example,<div>
<br></div><div style=3D"background-color:rgb(250,250,250);border:1px solid =
rgb(187,187,187);word-wrap:break-word"><code><div><span style=3D"color:#008=
">namespace</span><span style> X </span><span style=3D"color:#660">{</span>=
<span style><br>
=A0 =A0 </span><span style=3D"color:#008">template</span><span style=3D"col=
or:#660">&lt;</span><span style=3D"color:#008">typename</span><span style> =
L</span><span style=3D"color:#660">,</span><span style> </span><span style=
=3D"color:#008">typename</span><span style> R</span><span style=3D"color:#6=
60">&gt;</span><span style> L </span><span style=3D"color:#008">operator</s=
pan><span style=3D"color:#660">+(</span><span style>L l</span><span style=
=3D"color:#660">,</span><span style> R r</span><span style=3D"color:#660">)=
</span><span style> </span><span style=3D"color:#660">{</span><span style><=
br>
=A0 =A0 =A0 =A0 </span><span style=3D"color:#800">//...</span><span style><=
br>=A0 =A0 </span><span style=3D"color:#660">}</span><span style><br>=A0 =
=A0 </span><span style=3D"color:#008">auto</span><span style> f</span><span=
 style=3D"color:#660">()</span><span style> </span><span style=3D"color:#66=
0">{</span><span style><br>
=A0 =A0 =A0 =A0 </span><span style=3D"color:#008">return</span><span style>=
 </span><span style=3D"color:#660">[]</span><span style> </span><span style=
=3D"color:#660">{};</span><span style><br>=A0 =A0 </span><span style=3D"col=
or:#660">}</span><span style><br>
</span><span style=3D"color:#660">};</span><span style><br></span><span sty=
le=3D"color:#008">int</span><span style> main</span><span style=3D"color:#6=
60">()</span><span style> </span><span style=3D"color:#660">{</span><span s=
tyle><br>
=A0 =A0 </span><span style=3D"color:#066">1</span><span style> </span><span=
 style=3D"color:#660">+</span><span style> X</span><span style=3D"color:#66=
0">::</span><span style>f</span><span style=3D"color:#660">();</span><span =
style> </span><span style=3D"color:#800">// Fail</span><span style><br>
</span><span style=3D"color:#660">}</span></div></code></div><div><br></div=
><div>I propose that the wording be changed so that lambdas&#39; associated=
 namespace should be the most nested namespace containing whatever scope th=
ey are declared in. Having operators available to work on lambdas considera=
bly simplifies certain functional APIs, as you can just return a lambda dir=
ectly. However, the current wording would require using hand-created types =
purely for the purpose of ADL.</div>
</blockquote><div><br></div><div>Seems.. ..reasonable, I guess. I have trou=
ble imagining when I would want to use such a feature, so if you could<br>p=
rovide a bit more complete example, that would be nice.<br></div></div>
</div></div>

<p></p>

-- <br />
&nbsp;<br />
--- <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 std-proposals+unsubscribe@isocpp.org.<br />
To post to this group, send email to std-proposals@isocpp.org.<br />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/?hl=3Den">http://groups.google.com/a/isocpp.org/group/std-pro=
posals/?hl=3Den</a>.<br />
&nbsp;<br />
&nbsp;<br />

--90e6ba308f8290f13404dda00173--

.
