220 7010 <525031B5.80202@wanadoo.fr> article
Path: news.gmane.org!not-for-mail
From: "Vicente J. Botet Escriba" <vicente.botet@wanadoo.fr>
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Re: Re: Unnamed LValues
Date: Sat, 05 Oct 2013 17:35:17 +0200
Lines: 290
Approved: news@gmane.org
Message-ID: <525031B5.80202@wanadoo.fr>
References: <CADbh+eSOH540anYnezFkm4_wK+MCtMh-01XNzAcMQMebdCPgRQ@mail.gmail.com> <0d9b268f-cd3a-4048-a0a3-50cff02b28ce@isocpp.org>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: plane.gmane.org
Mime-Version: 1.0
Content-Type: multipart/alternative;
 boundary="------------060309030001090105030400"
X-Trace: ger.gmane.org 1380987321 17284 80.91.229.3 (5 Oct 2013 15:35:21 GMT)
X-Complaints-To: usenet@ger.gmane.org
NNTP-Posting-Date: Sat, 5 Oct 2013 15:35:21 +0000 (UTC)
To: std-proposals@isocpp.org
Original-X-From: std-proposals+bncBDH67CONY4PBBN7DYCJAKGQEYJ6VU7Q@isocpp.org Sat Oct 05 17:35:24 2013
Return-path: <std-proposals+bncBDH67CONY4PBBN7DYCJAKGQEYJ6VU7Q@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-lb0-f200.google.com ([209.85.217.200])
	by plane.gmane.org with esmtp (Exim 4.69)
	(envelope-from <std-proposals+bncBDH67CONY4PBBN7DYCJAKGQEYJ6VU7Q@isocpp.org>)
	id 1VSTt3-0006qa-0C
	for gclcip-std-proposals@m.gmane.org; Sat, 05 Oct 2013 17:35:21 +0200
Original-Received: by mail-lb0-f200.google.com with SMTP id y6sf6653364lbh.11
        for <gclcip-std-proposals@m.gmane.org>; Sat, 05 Oct 2013 08:35:20 -0700 (PDT)
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20130820;
        h=message-id:date:from:user-agent:mime-version:to:subject:references
         :in-reply-to:x-original-sender:x-original-authentication-results
         :reply-to:precedence:mailing-list:list-id:list-post:list-help
         :list-archive:list-subscribe:list-unsubscribe:content-type;
        bh=a5Mu87vdeYqvM13w6+XGXwDA5UQCgSd4/ipXxhHIa9w=;
        b=T422F4mR3vHe96yZoCellZD5vC+oQKQ16tYrEtAkDFjeEzw3cqy35GxBsK2xuEwLry
         iBAsGa4DPTiLfFh0qs0g/aW1e0DfvYmO/EqnG2X1fB0jwfo98yBpM1PvtQQcydty/rDS
         I2F6Ux/XdwCOPwBxTLQkgwoi4yiIdC92aMI96g1R5l+PAy4KVLUWD/B3+UQqLtF9Cx+F
         0bpZBeBRGXdSOgUxhUsjFU2oAvj+jRtyM5prxdjkY64xm2u9KWZKRGHaHLMRVkl1GX8/
         x2Af5Fl7o/ZBxCwAbha9subG+ms4K+PqABStDd/NxVW0gK5XyZnxs/8fepJisGCn6Ogk
         RrPA==
X-Received: by 10.180.208.67 with SMTP id mc3mr5613496wic.1.1380987320204;
        Sat, 05 Oct 2013 08:35:20 -0700 (PDT)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.180.107.41 with SMTP id gz9ls582788wib.33.gmail; Sat, 05 Oct
 2013 08:35:19 -0700 (PDT)
X-Received: by 10.15.94.201 with SMTP id bb49mr31999928eeb.23.1380987319078;
        Sat, 05 Oct 2013 08:35:19 -0700 (PDT)
Original-Received: from smtp.smtpout.orange.fr (smtp08.smtpout.orange.fr. [80.12.242.130])
        by mx.google.com with ESMTP id 7si15346091eeu.188.1969.12.31.16.00.00;
        Sat, 05 Oct 2013 08:35:19 -0700 (PDT)
Received-SPF: neutral (google.com: 80.12.242.130 is neither permitted nor denied by best guess record for domain of vicente.botet@wanadoo.fr) client-ip=80.12.242.130;
Original-Received: from android-895509e2ec940b49.home ([92.139.19.223])
	by mwinf5d16 with ME
	id ZTbH1m00J4omr7803TbJRz; Sat, 05 Oct 2013 17:35:18 +0200
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7; rv:17.0) Gecko/20130801 Thunderbird/17.0.8
In-Reply-To: <0d9b268f-cd3a-4048-a0a3-50cff02b28ce@isocpp.org>
X-Original-Sender: vicente.botet@wanadoo.fr
X-Original-Authentication-Results: mx.google.com;       spf=neutral
 (google.com: 80.12.242.130 is neither permitted nor denied by best guess
 record for domain of vicente.botet@wanadoo.fr) smtp.mail=vicente.botet@wanadoo.fr
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>, <mailto:std-proposals@isocpp.org>
List-Help: <http://support.google.com/a/isocpp.org/bin/topic.py?topic=25838>, <mailto:std-proposals+help@isocpp.org>
List-Archive: <http://groups.google.com/a/isocpp.org/group/std-proposals/>
List-Subscribe: <http://groups.google.com/a/isocpp.org/group/std-proposals/subscribe>,
 <mailto:std-proposals+subscribe@isocpp.org>
List-Unsubscribe: <http://groups.google.com/a/isocpp.org/group/std-proposals/subscribe>,
 <mailto:googlegroups-manage+399137483710+unsubscribe@googlegroups.com>
Xref: news.gmane.org gmane.comp.lang.c++.isocpp.proposals:7010
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/7010>

This is a multi-part message in MIME format.
--------------060309030001090105030400
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: quoted-printable

Le 05/10/13 16:43, snk_kid a =E9crit :
> A simpler solution would be to use plain higher-order functions,=20
> with-function patterns are very common in functional languages,=20
> something like:
>
> |
> template<typenameFunction>
> autowith_freeze(SomeWxWidgetClass*w,Function&&fn)->decltype(fn())
> {
> WxScopeFreezescoped_freeze(w);
> returnfn();
> }
> |
>
> example usage:
>
> |
> with_freeze(this,[&]()->void
> {
>     with_freeze(other,[&]()->void
> {
> // do stuff.
> });
> });
> |
>
> If you don't like the nesting you may be able to generalize this in=20
> various ways like using variadic templates so it may look more like this:
>
> |
> |with_freeze(this, ||||other,||[&]()->void
> {
> // do stuff.
> });
> |
> |
>
>
All this is useful, but this doesn't support control flow leaving the block=
..

I proposed in [1] let-in statement and anonymous variable. With this=20
extension your PO could write it as

WxScopeFreeze auto(this) *:* WxScopeFreeze auto(Other) *:* {
}

Whether ':' is appropriated to introduce the new variables could be=20
discussed.

if the user has a Freeze function it could be even clearer

auto=3DFreeze(this) : auto=3DFreeze(Other) : {
}


Best,
Vicente

[1] let-in statements and anonymous variables -=20
https://groups.google.com/a/isocpp.org/forum/#!topic/std-proposals/BfAtczj8=
1Kg

--=20

---=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.
Visit this group at http://groups.google.com/a/isocpp.org/group/std-proposa=
ls/.

--------------060309030001090105030400
Content-Type: text/html; charset=ISO-8859-1

<html>
  <head>
    <meta content="text/html; charset=ISO-8859-1"
      http-equiv="Content-Type">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    <div class="moz-cite-prefix">Le 05/10/13 16:43, snk_kid a &eacute;crit&nbsp;:<br>
    </div>
    <blockquote
      cite="mid:0d9b268f-cd3a-4048-a0a3-50cff02b28ce@isocpp.org"
      type="cite">
      <div dir="ltr">A simpler solution would be to use plain
        higher-order functions, with-function patterns are very common
        in functional languages, something like:<br>
        <br>
        <div class="prettyprint" style="background-color: rgb(250, 250,
          250); border-color: rgb(187, 187, 187); border-style: solid;
          border-width: 1px; word-wrap: break-word;"><code
            class="prettyprint">
            <div class="subprettyprint"><span style="color: #008;"
                class="styled-by-prettify">template</span><span
                style="color: #000;" class="styled-by-prettify"> </span><span
                style="color: #660;" class="styled-by-prettify">&lt;</span><span
                style="color: #000;" class="styled-by-prettify"> </span><span
                style="color: #008;" class="styled-by-prettify">typename</span><span
                style="color: #000;" class="styled-by-prettify"> </span><span
                style="color: #606;" class="styled-by-prettify">Function</span><span
                style="color: #000;" class="styled-by-prettify"> </span><span
                style="color: #660;" class="styled-by-prettify">&gt;</span><span
                style="color: #000;" class="styled-by-prettify"><br>
              </span><span style="color: #008;"
                class="styled-by-prettify">auto</span><span
                style="color: #000;" class="styled-by-prettify">
                with_freeze</span><span style="color: #660;"
                class="styled-by-prettify">(</span><span style="color:
                #606;" class="styled-by-prettify">SomeWxWidgetClass</span><span
                style="color: #660;" class="styled-by-prettify">*</span><span
                style="color: #000;" class="styled-by-prettify"> w</span><span
                style="color: #660;" class="styled-by-prettify">,</span><span
                style="color: #000;" class="styled-by-prettify"> </span><span
                style="color: #606;" class="styled-by-prettify">Function</span><span
                style="color: #660;" class="styled-by-prettify">&amp;&amp;</span><span
                style="color: #000;" class="styled-by-prettify"> fn</span><span
                style="color: #660;" class="styled-by-prettify">)</span><span
                style="color: #000;" class="styled-by-prettify"> </span><span
                style="color: #660;" class="styled-by-prettify">-&gt;</span><span
                style="color: #000;" class="styled-by-prettify"> </span><span
                style="color: #008;" class="styled-by-prettify">decltype</span><span
                style="color: #660;" class="styled-by-prettify">(</span><span
                style="color: #000;" class="styled-by-prettify">fn</span><span
                style="color: #660;" class="styled-by-prettify">())</span><span
                style="color: #000;" class="styled-by-prettify"><br>
              </span><span style="color: #660;"
                class="styled-by-prettify">{</span><span style="color:
                #000;" class="styled-by-prettify"><br>
                &nbsp; &nbsp; </span><span style="color: #606;"
                class="styled-by-prettify">WxScopeFreeze</span><span
                style="color: #000;" class="styled-by-prettify">
                scoped_freeze</span><span style="color: #660;"
                class="styled-by-prettify">(</span><span style="color:
                #000;" class="styled-by-prettify">w</span><span
                style="color: #660;" class="styled-by-prettify">);</span><span
                style="color: #000;" class="styled-by-prettify"><br>
                &nbsp; &nbsp; </span><span style="color: #008;"
                class="styled-by-prettify">return</span><span
                style="color: #000;" class="styled-by-prettify"> fn</span><span
                style="color: #660;" class="styled-by-prettify">();</span><span
                style="color: #000;" class="styled-by-prettify"><br>
              </span><span style="color: #660;"
                class="styled-by-prettify">}</span><span style="color:
                #000;" class="styled-by-prettify"><br>
              </span></div>
          </code></div>
        <br>
        example usage:<br>
        <br>
        <div class="prettyprint" style="background-color: rgb(250, 250,
          250); border-color: rgb(187, 187, 187); border-style: solid;
          border-width: 1px; word-wrap: break-word;"><code
            class="prettyprint">
            <div class="subprettyprint"><span style="color: #000;"
                class="styled-by-prettify">with_freeze</span><span
                style="color: #660;" class="styled-by-prettify">(</span><span
                style="color: #008;" class="styled-by-prettify">this</span><span
                style="color: #660;" class="styled-by-prettify">,</span><span
                style="color: #000;" class="styled-by-prettify"> </span><span
                style="color: #660;" class="styled-by-prettify">[&amp;]()</span><span
                style="color: #000;" class="styled-by-prettify"> </span><span
                style="color: #660;" class="styled-by-prettify">-&gt;</span><span
                style="color: #000;" class="styled-by-prettify"> </span><span
                style="color: #008;" class="styled-by-prettify">void</span><span
                style="color: #000;" class="styled-by-prettify"><br>
              </span><span style="color: #660;"
                class="styled-by-prettify">{</span><span style="color:
                #000;" class="styled-by-prettify"><br>
                &nbsp; &nbsp; with_freeze</span><span style="color: #660;"
                class="styled-by-prettify">(</span><span style="color:
                #000;" class="styled-by-prettify">other</span><span
                style="color: #660;" class="styled-by-prettify">,</span><span
                style="color: #000;" class="styled-by-prettify"> </span><span
                style="color: #660;" class="styled-by-prettify">[&amp;]()</span><span
                style="color: #000;" class="styled-by-prettify"> </span><span
                style="color: #660;" class="styled-by-prettify">-&gt;</span><span
                style="color: #000;" class="styled-by-prettify"> </span><span
                style="color: #008;" class="styled-by-prettify">void</span><span
                style="color: #000;" class="styled-by-prettify"><br>
                &nbsp; &nbsp; </span><span style="color: #660;"
                class="styled-by-prettify">{</span><span style="color:
                #000;" class="styled-by-prettify"><br>
                &nbsp; &nbsp; &nbsp; &nbsp; </span><span style="color: #800;"
                class="styled-by-prettify">// do stuff.</span><span
                style="color: #000;" class="styled-by-prettify"><br>
                &nbsp; &nbsp; </span><span style="color: #660;"
                class="styled-by-prettify">});</span><span style="color:
                #000;" class="styled-by-prettify"><br>
              </span><span style="color: #660;"
                class="styled-by-prettify">});</span><span style="color:
                #000;" class="styled-by-prettify"><br>
              </span></div>
          </code></div>
        <br>
        If you don't like the nesting you may be able to generalize this
        in various ways like using variadic templates so it may look
        more like this:<br>
        <br>
        <div class="prettyprint" style="background-color: rgb(250, 250,
          250); border-color: rgb(187, 187, 187); border-style: solid;
          border-width: 1px; word-wrap: break-word;"><code
            class="prettyprint">
            <div class="subprettyprint"><code class="prettyprint"><span
                  style="color: #000;" class="styled-by-prettify">with_freeze</span><span
                  style="color: #660;" class="styled-by-prettify">(</span><span
                  style="color: #008;" class="styled-by-prettify">this</span><span
                  style="color: #660;" class="styled-by-prettify">, </span></code><code
                class="prettyprint"><span style="color: #660;"
                  class="styled-by-prettify"><code class="prettyprint"><code
                      class="prettyprint"><span
                        class="styled-by-prettify"></span><span
                        style="color: #000;" class="styled-by-prettify">other</span><span
                        class="styled-by-prettify">,</span></code></code></span><span
                  style="color: #000;" class="styled-by-prettify"> </span><span
                  style="color: #660;" class="styled-by-prettify">[&amp;]()</span><span
                  style="color: #000;" class="styled-by-prettify"> </span><span
                  style="color: #660;" class="styled-by-prettify">-&gt;</span><span
                  style="color: #000;" class="styled-by-prettify"> </span><span
                  style="color: #008;" class="styled-by-prettify">void</span><span
                  style="color: #000;" class="styled-by-prettify"><br>
                </span><span style="color: #660;"
                  class="styled-by-prettify">{</span><span style="color:
                  #000;" class="styled-by-prettify"><br>
                  &nbsp;&nbsp; </span><span style="color: #000;"
                  class="styled-by-prettify"></span><span style="color:
                  #800;" class="styled-by-prettify">// do stuff.</span><span
                  style="color: #000;" class="styled-by-prettify"><br>
                </span><span style="color: #660;"
                  class="styled-by-prettify">});</span><span
                  style="color: #000;" class="styled-by-prettify"><br>
                </span></code><span style="color: #660;"
                class="styled-by-prettify"></span></div>
          </code></div>
        <br>
      </div>
      <br>
    </blockquote>
    All this is useful, but this doesn't support control flow leaving
    the block.<br>
    <br>
    I proposed in [1] let-in statement and anonymous variable. With this
    extension your PO could write it as<br>
    <br>
    <div>WxScopeFreeze auto(this) <b>:</b> WxScopeFreeze auto(Other) <b>:</b>
      {<br>
      }<br>
    </div>
    <br>
    Whether ':' is appropriated to introduce the new variables could be
    discussed.<br>
    <br>
    if the user has a Freeze function it could be even clearer<br>
    <br>
    auto=Freeze(this) : auto=Freeze(Other) : { <br>
    }<br>
    <br>
    <br>
    Best,<br>
    Vicente<br>
    <br>
    [1]
    <meta http-equiv="content-type" content="text/html;
      charset=ISO-8859-1">
    <span id="t-t" class="GJHYW0UCIXB">let-in statements and anonymous
      variables - </span><a class="moz-txt-link-freetext" href="https://groups.google.com/a/isocpp.org/forum/#!topic/std-proposals/BfAtczj81Kg">https://groups.google.com/a/isocpp.org/forum/#!topic/std-proposals/BfAtczj81Kg</a><br>
    <br>
  </body>
</html>

<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 email 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="http://groups.google.com/a/isocpp.org/group/std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/</a>.<br />

--------------060309030001090105030400--

.
