220 4645 <7fed9a71-8e54-47e7-98cc-98f61829fa36@isocpp.org> article
Path: news.gmane.org!not-for-mail
From: Nicol Bolas <jmckesson@gmail.com>
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Re: Changing lambda scope
Date: Mon, 27 May 2013 23:26:14 -0700 (PDT)
Lines: 202
Approved: news@gmane.org
Message-ID: <7fed9a71-8e54-47e7-98cc-98f61829fa36@isocpp.org>
References: <ae01f736-d3ac-48d6-981f-702b9ab2b3b3@isocpp.org>
 <CAFk2RUax65FEaDaeKCEdBig+bq4W4u_+39R3hsdBuyiOj-rpjA@mail.gmail.com>
 <90375ba5-8005-47da-9e84-eee151d0ba0a@isocpp.org>
 <CAFk2RUZzoT4HH8FYDJqVbj4dU+s9zUQRpYX9seprDSHDxF7U6w@mail.gmail.com>
 <CAOfiQqm2hNSOmxoSAxBSS0dL6fB=ZcbxHZDxhPD5Z_Q69hrghA@mail.gmail.com>
 <2e120ca5-740b-4301-8a32-8ac5035fa108@isocpp.org>
 <0df9d0d8-a752-4841-ba02-54780590f722@isocpp.org>
 <CAGsORuB9UByzMkk8PZC67ByrvxKFmud51jgEZxWq31TAy8Zf=g@mail.gmail.com>
 <87d2sd5k77.fsf@euclid.axiomatics.org>
 <c110a614-dc6c-4464-905c-7fba2d51c211@isocpp.org>
 <87sj17anqh.fsf@euclid.axiomatics.org>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: plane.gmane.org
Mime-Version: 1.0
Content-Type: multipart/alternative; 
	boundary="----=_Part_299_28340376.1369722374219"
X-Trace: ger.gmane.org 1369722378 4234 80.91.229.3 (28 May 2013 06:26:18 GMT)
X-Complaints-To: usenet@ger.gmane.org
NNTP-Posting-Date: Tue, 28 May 2013 06:26:18 +0000 (UTC)
Cc: Nicol Bolas <jmckesson@gmail.com>, gdr@axiomatics.org
To: std-proposals@isocpp.org
Original-X-From: std-proposals+bncBCEKFTV6ZUMBBCE4SGGQKGQEAR7G35I@isocpp.org Tue May 28 08:26:18 2013
Return-path: <std-proposals+bncBCEKFTV6ZUMBBCE4SGGQKGQEAR7G35I@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-ob0-f198.google.com ([209.85.214.198])
	by plane.gmane.org with esmtp (Exim 4.69)
	(envelope-from <std-proposals+bncBCEKFTV6ZUMBBCE4SGGQKGQEAR7G35I@isocpp.org>)
	id 1UhDMP-0008Mk-Kv
	for gclcip-std-proposals@m.gmane.org; Tue, 28 May 2013 08:26:17 +0200
Original-Received: by mail-ob0-f198.google.com with SMTP id er7sf33495725obc.9
        for <gclcip-std-proposals@m.gmane.org>; Mon, 27 May 2013 23:26:16 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=20120113;
        h=x-beenthere:date:from:to:cc:message-id:in-reply-to:references
         :subject:mime-version:x-original-sender:reply-to:precedence
         :mailing-list:list-id:x-google-group-id:list-post:list-help
         :list-archive:list-subscribe:list-unsubscribe:content-type;
        bh=sh6+Z4qq/oAYrXOzX8jq9dPIH5NCwUHhfeaVB3dq8dU=;
        b=KvD5Q88Dw8eKDyzJmPDWKpcRVLCRrMQfkGVhVnb5b6J41OaNtHAaLZAnvciZfZ53Ys
         E75kgE3vxNp/5uYgzek1WI/No/N1IKBRrKrOZbZ7MIA6QlWMu0puRcITjF981gSnavyQ
         5kyfjCtGPWKgd014UWRLrtt/9e3UXrj4FXPLXZjoL9afwjzAFo305JCbFW5J0iBAYbBD
         YBe9w+z615OFiUpvQFRuWYPCjYDLlgoT4GhoQ8jh/stmt8iRWOwE8jdQvP8cNnP+nliG
         iCJm+7s8hMWRcY/SOtUxrFasxRxlV4lzPBNcjEJdBjYPpmIECchf8YGosYwGXaoG+sNs
         dcLA==
X-Received: by 10.42.231.210 with SMTP id jr18mr22568598icb.7.1369722376627;
        Mon, 27 May 2013 23:26:16 -0700 (PDT)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.50.117.65 with SMTP id kc1ls2263967igb.3.gmail; Mon, 27 May
 2013 23:26:15 -0700 (PDT)
X-Received: by 10.50.147.98 with SMTP id tj2mr1153590igb.10.1369722375527;
        Mon, 27 May 2013 23:26:15 -0700 (PDT)
In-Reply-To: <87sj17anqh.fsf@euclid.axiomatics.org>
X-Original-Sender: jmckesson@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:4645
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/4645>

------=_Part_299_28340376.1369722374219
Content-Type: text/plain; charset=ISO-8859-1

On Monday, May 27, 2013 6:37:26 PM UTC-7, Gabriel Dos Reis wrote:
>
> Nicol Bolas <jmck...@gmail.com <javascript:>> writes: 
>
> | On Sunday, May 26, 2013 5:40:28 PM UTC-7, Gabriel Dos Reis wrote: 
> | 
> |     Zhihao Yuan <lic...@gmail.com> writes: 
> | 
> |     | On Sun, May 26, 2013 at 7:17 PM, Nicol Bolas <jmck...@gmail.com> 
> wrote: 
> |     | > A lambda is nothing special; it's just shorthand notation for a 
> type 
> |     | > declared at that scope. We shouldn't have special-case language 
> in the 
> |     | > standard that says "if the local type is a lambda type, blah 
> blah". 
> |     | 
> |     | I don't agree.  Lambda is special, conceptually, as a language 
> structure. 
> |     | It's described in terms of a class / class template does not mean 
> its 
> |     | semantics has to be limited by class / class template. 
> | 
> |     I tend to agree that a lambda expression is a fundamental language 
> |     construct (from semantics point of view), and it is unfortunate that 
> we 
> |     somehow think of it in terms of local classes.  We shouldn't think 
> of 
> |     lambdas in terms of implementation details. 
> | 
> | 
> | Whatever they may be "from semantics point of view", they are still just 
> types. 
>
> I am afraid I do not understand by what you mean by that sentence. 
> Could you elaborate?
>

Lambda expressions create types. I'm not really sure what more there is to 
elaborate on.

You can think of a lambda expression as making a function. You can think of 
it as its own special syntactic construct. But as far as the standard is 
concerned, lambda expressions are just a shorthand way for creating an 
unnamed type and instantiating it. And that's good; see below.

| The fact that there's nothing a lambda can do which you can't do yourself 
> is a 
> | strength of C++ lambdas, not a weakness. 
>
> Again, I am afraid I do not understand this statement.
>

This:

auto x = []() {...};

Should always be in every way equivalent to this:

struct __unnamed__
{
  auto operator() {...}
};
auto x = __unnamed__{};

Currently, that's how lambdas work. And that is good.

It allows you to turn a lambda into a struct if you feel like it. That is 
useful, because sometimes lambdas get very large, or you need to add 
features to them that are just not possible.

Lambdas are nothing more than a quick way to write a type with an 
operator() overload. They should not have special semantics that you cannot 
replicate yourself (outside of being unnamed).

-- 

--- 
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.



------=_Part_299_28340376.1369722374219
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

On Monday, May 27, 2013 6:37:26 PM UTC-7, Gabriel Dos Reis wrote:<blockquot=
e class=3D"gmail_quote" style=3D"margin: 0;margin-left: 0.8ex;border-left: =
1px #ccc solid;padding-left: 1ex;">Nicol Bolas &lt;<a href=3D"javascript:" =
target=3D"_blank" gdf-obfuscated-mailto=3D"l0LWSzILX4MJ">jmck...@gmail.com<=
/a>&gt; writes:
<br>
<br>| On Sunday, May 26, 2013 5:40:28 PM UTC-7, Gabriel Dos Reis wrote:
<br>|=20
<br>| &nbsp; &nbsp; Zhihao Yuan &lt;<a>lic...@gmail.com</a>&gt; writes:
<br>|=20
<br>| &nbsp; &nbsp; | On Sun, May 26, 2013 at 7:17 PM, Nicol Bolas &lt;<a>j=
mck...@gmail.com</a>&gt; wrote:
<br>| &nbsp; &nbsp; | &gt; A lambda is nothing special; it's just shorthand=
 notation for a type
<br>| &nbsp; &nbsp; | &gt; declared at that scope. We shouldn't have specia=
l-case language in the
<br>| &nbsp; &nbsp; | &gt; standard that says "if the local type is a lambd=
a type, blah blah".
<br>| &nbsp; &nbsp; |
<br>| &nbsp; &nbsp; | I don't agree. &nbsp;Lambda is special, conceptually,=
 as a language structure.
<br>| &nbsp; &nbsp; | It's described in terms of a class / class template d=
oes not mean its
<br>| &nbsp; &nbsp; | semantics has to be limited by class / class template=
..
<br>|=20
<br>| &nbsp; &nbsp; I tend to agree that a lambda expression is a fundament=
al language
<br>| &nbsp; &nbsp; construct (from semantics point of view), and it is unf=
ortunate that we
<br>| &nbsp; &nbsp; somehow think of it in terms of local classes. &nbsp;We=
 shouldn't think of
<br>| &nbsp; &nbsp; lambdas in terms of implementation details.
<br>|=20
<br>|=20
<br>| Whatever they may be "from semantics point of view", they are still j=
ust types.
<br>
<br>I am afraid I do not understand by what you mean by that sentence.
<br>Could you elaborate?<br></blockquote><div><br>Lambda expressions create=
 types. I'm not really sure what more there is to elaborate on.<br><br>You =
can think of a lambda expression as making a function. You can think of it =
as its own special syntactic construct. But as far as the standard is conce=
rned, lambda expressions are just a shorthand way for creating an unnamed t=
ype and instantiating it. And that's good; see below.<br><br></div><blockqu=
ote class=3D"gmail_quote" style=3D"margin: 0;margin-left: 0.8ex;border-left=
: 1px #ccc solid;padding-left: 1ex;">
| The fact that there's nothing a lambda can do which you can't do yourself=
 is a
<br>| strength of C++ lambdas, not a weakness.=20
<br>
<br>Again, I am afraid I do not understand this statement.<br></blockquote>=
<div><br>This:<br><br><div class=3D"prettyprint" style=3D"background-color:=
 rgb(250, 250, 250); border-color: rgb(187, 187, 187); border-style: solid;=
 border-width: 1px; word-wrap: break-word;"><code class=3D"prettyprint"><di=
v class=3D"subprettyprint"><span style=3D"color: #008;" class=3D"styled-by-=
prettify">auto</span><span style=3D"color: #000;" class=3D"styled-by-pretti=
fy"> x </span><span style=3D"color: #660;" class=3D"styled-by-prettify">=3D=
</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 st=
yle=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"co=
lor: #660;" class=3D"styled-by-prettify">{...};</span><span style=3D"color:=
 #000;" class=3D"styled-by-prettify"><br></span></div></code></div><br>Shou=
ld always be in every way equivalent to this:<br><br><div class=3D"prettypr=
int" style=3D"background-color: rgb(250, 250, 250); border-color: rgb(187, =
187, 187); border-style: solid; border-width: 1px; word-wrap: break-word;">=
<code class=3D"prettyprint"><div class=3D"subprettyprint"><span style=3D"co=
lor: #008;" class=3D"styled-by-prettify">struct</span><span style=3D"color:=
 #000;" class=3D"styled-by-prettify"> __unnamed__<br></span><span style=3D"=
color: #660;" class=3D"styled-by-prettify">{</span><span style=3D"color: #0=
00;" class=3D"styled-by-prettify"><br>&nbsp; </span><span style=3D"color: #=
008;" class=3D"styled-by-prettify">auto</span><span style=3D"color: #000;" =
class=3D"styled-by-prettify"> </span><span style=3D"color: #008;" class=3D"=
styled-by-prettify">operator</span><span style=3D"color: #660;" class=3D"st=
yled-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>=
</span><span style=3D"color: #660;" class=3D"styled-by-prettify">};</span><=
span style=3D"color: #000;" class=3D"styled-by-prettify"><br></span><span s=
tyle=3D"color: #008;" class=3D"styled-by-prettify">auto</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"> x </span><span style=3D"col=
or: #660;" class=3D"styled-by-prettify">=3D</span><span style=3D"color: #00=
0;" class=3D"styled-by-prettify"> __unnamed__</span><span style=3D"color: #=
660;" class=3D"styled-by-prettify">{};</span><span style=3D"color: #000;" c=
lass=3D"styled-by-prettify"><br></span></div></code></div><br>Currently, th=
at's how lambdas work. And that is good.<br><br>It allows you to turn a lam=
bda into a struct if you feel like it. That is useful, because sometimes la=
mbdas get very large, or you need to add features to them that are just not=
 possible.<br><br>Lambdas are nothing more than a quick way to write a type=
 with an operator() overload. They should not have special semantics that y=
ou cannot replicate yourself (outside of being unnamed).<br></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 />

------=_Part_299_28340376.1369722374219--

.
