220 13874 <16366a2f-03b6-4e2a-9007-7819afe28460@isocpp.org> article
Path: news.gmane.org!not-for-mail
From: Michael Bruck <bruck.michael@gmail.com>
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Re: Proposal for a delete expression for local variables
Date: Wed, 15 Oct 2014 02:18:59 -0700 (PDT)
Lines: 562
Approved: news@gmane.org
Message-ID: <16366a2f-03b6-4e2a-9007-7819afe28460@isocpp.org>
References: <e8ee92d8-0018-45a2-b87a-2d87f13047b4@isocpp.org>
 <CAB+4KH+8bgPbTpxV7pubCNW_1Yiupff+tzuoMmzpZzXxoLwnSg@mail.gmail.com>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: plane.gmane.org
Mime-Version: 1.0
Content-Type: multipart/alternative; 
	boundary="----=_Part_2498_80284596.1413364739294"
X-Trace: ger.gmane.org 1413364748 24814 80.91.229.3 (15 Oct 2014 09:19:08 GMT)
X-Complaints-To: usenet@ger.gmane.org
NNTP-Posting-Date: Wed, 15 Oct 2014 09:19:08 +0000 (UTC)
To: std-proposals@isocpp.org
Original-X-From: std-proposals+bncBDO2X46R4AKRBA7Y7CQQKGQE4EUDJSI@isocpp.org Wed Oct 15 11:19:02 2014
Return-path: <std-proposals+bncBDO2X46R4AKRBA7Y7CQQKGQE4EUDJSI@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-pd0-f200.google.com ([209.85.192.200])
	by plane.gmane.org with esmtp (Exim 4.69)
	(envelope-from <std-proposals+bncBDO2X46R4AKRBA7Y7CQQKGQE4EUDJSI@isocpp.org>)
	id 1XeKjV-0005qF-FH
	for gclcip-std-proposals@m.gmane.org; Wed, 15 Oct 2014 11:19:01 +0200
Original-Received: by mail-pd0-f200.google.com with SMTP id ft15sf4384877pdb.11
        for <gclcip-std-proposals@m.gmane.org>; Wed, 15 Oct 2014 02:19:00 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=20120113;
        h=date:from:to:message-id:in-reply-to:references:subject:mime-version
         :x-original-sender:reply-to:precedence:mailing-list:list-id
         :list-post:list-help:list-archive:list-subscribe:list-unsubscribe
         :content-type;
        bh=Re+JI3cRIWBY+0EHXVDwCk340t+XgT3YOK00BI87hBg=;
        b=KZj6AT24uZ/Ptd+kZH2d70UA72yZQ91HWNgiEUJd6nRXkBKV6nO7SyLklFV1c07MSJ
         yhHHWc4T4coMacFNN8H41x+3Jyg5c6wHXBRp3iPIvxDZIEIz0BCG0r/zFt6ONH0c9puJ
         nLZGkqJuapYl2B7tHbPnBPZSixwWnWYgnsktrHWDBpVqkLvJL9F38cKyBk4Fn3brDbEu
         Z4EOaHKfRzUCoNK34K5JwF50Q20qzfKjhp5hKp3qkOVFOBIOKWYUf8dKaO/xmUVptIZu
         zm6Y9DptJzlkq/4W+fVo8UCuH6CiJr83RV6vzb0e+L42SRfT6xhnx2d/6kjpxCiL3ERe
         duVw==
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:message-id:in-reply-to:references
         :subject:mime-version:x-original-sender:reply-to:precedence
         :mailing-list:list-id:list-post:list-help:list-archive
         :list-subscribe:list-unsubscribe:content-type;
        bh=Re+JI3cRIWBY+0EHXVDwCk340t+XgT3YOK00BI87hBg=;
        b=ddls2pRwByZHhiu/yh4g0er0qS9uRsRs3o1rmmGjk05yx/eCBOPsB+hjj/WA02hAC7
         zTK+CurmvjQPdI0PPFAvAvyH6uqvKE1u7as5HfQ8Fsqx6HwszwODP3INaY5evmd+MlZI
         e63CkZXXbI93CyMzkVr37jukjzAp7otFad1NApftmXo/isAyqU3kJh9I6e2JoBmCn0Sv
         uFEEoxocPZzS7/BQLALUVWqcHJRoPgK9QRIufbWxsNAEyYdSyJZqpTC4NiIPpDnC+hIZ
         sc5ivFXsGwQ0BjSGyRL+ufY6j6lJsVb6cvFDpshPCkTGCXqc9T3QETgpBCDGF+U9PJdB
         uCCQ==
X-Gm-Message-State: ALoCoQlCN7yT0P/kPOg896JO1ZNSdmhW3/mHHInE7m5UNRbNJgg6NLO8IMQz8MbzU5IRfBhAEuPj
X-Received: by 10.66.222.98 with SMTP id ql2mr7389410pac.28.1413364740392;
        Wed, 15 Oct 2014 02:19:00 -0700 (PDT)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.140.107.166 with SMTP id h35ls144375qgf.80.gmail; Wed, 15 Oct
 2014 02:18:59 -0700 (PDT)
X-Received: by 10.140.20.175 with SMTP id 44mr173656qgj.4.1413364739628;
        Wed, 15 Oct 2014 02:18:59 -0700 (PDT)
In-Reply-To: <CAB+4KH+8bgPbTpxV7pubCNW_1Yiupff+tzuoMmzpZzXxoLwnSg@mail.gmail.com>
X-Original-Sender: bruck.michael@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>, <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: <mailto:googlegroups-manage+399137483710+unsubscribe@googlegroups.com>,
 <http://groups.google.com/a/isocpp.org/group/std-proposals/subscribe>
Xref: news.gmane.org gmane.comp.lang.c++.isocpp.proposals:13874
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/13874>

------=_Part_2498_80284596.1413364739294
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

I think the proposal addresses a number of drawbacks with that approach. I=
=20
think that having a unified method to dispose of these objects without=20
needing special support in your library has clear advantages.=20

Michael

On Wednesday, October 15, 2014 10:36:03 AM UTC+2, Andrew Tomazos wrote:
>
> If your classes depend on destructor ordering, then you are doing too muc=
h=20
> in destructors, and are better off putting the interesting part of the=20
> destructor into a member function and explicitly calling it.  In the=20
> destructor you can check if it has been called and then either error or=
=20
> call it automatically.  The member function will have an expressive name=
=20
> that helps the reader understand what is going on, rather than hiding it =
in=20
> a nameless destructor.
>   -Andrew.
>
>
> On Wed, Oct 15, 2014 at 9:14 AM, Michael Bruck <bruck....@gmail.com=20
> <javascript:>> wrote:
>
>> Hello everyone,
>>
>>
>>
>> I am looking for feedback on the outline for a proposal below. I would=
=20
>> like to know if there is interest in such a feature and any ideas on=20
>> improvements.
>>
>>
>>
>>
>> Regards,
>>
>> Michael
>>
>>
>>
>> Deleting local variables
>> Summary
>>
>> This proposal introduces a way to end the scope of a variable before its=
=20
>> enclosing block ends.
>>
>> {
>>
>> std::string foo, bar;
>>
>> ...
>>
>> delete local foo, bar;
>>
>> ...
>>
>> }
>>
>> Motivation
>>
>> The =E2=80=9C} operator=E2=80=9D is powerful but but comes with a pre-de=
fined destruction=20
>> order which is not suitable for all applications. In real world programs=
=20
>> the desired scopes of objects are not always cleanly nested but sometime=
s=20
>> overlap in complex ways.
>>
>> Sometimes objects hold expensive resources and especially with=20
>> programming patterns like threading or resumable functions the resources=
=20
>> can remain blocked long after use if other functions in the same block=
=20
>> require a long time to complete.
>>
>> This leads to programming patterns that try to mitigate this problem in=
=20
>> suboptimal ways. A typical approach looks like:
>>
>> {
>>
>> auto file =3D file_open_rlock("data_snippet");
>>
>> auto blob =3D file.fetch_all();
>>
>> file.close();
>>
>> auto conn =3D connect_to_peer("192.128.0.1");
>>
>> conn.send(blob);
>>
>> blob.destroy();
>>
>> auto reply =3D conn.fetch_reply();
>>
>> conn.disconnect();
>>
>> auto file2 =3D file_create("output");
>>
>> file2.write(reply);
>>
>> reply.destroy();
>>
>> file2.close();
>>
>> }
>>
>> There are a number of problems with this solution:
>>
>>    -=20
>>   =20
>>    The library needs to provide a function that releases expensive=20
>>    resources in addition to the destructor.
>>    -=20
>>   =20
>>    The library needs to keep track of the additional state in which=20
>>    resources are freed but the object not yet destroyed.
>>    -=20
>>   =20
>>    The user needs to locate such a function and understand its semantics=
=20
>>    to see if it really releases enough resources.
>>    -=20
>>   =20
>>    The neutered object still lingers in some form on the stack until the=
=20
>>    end of the scope.
>>    -=20
>>   =20
>>    The compiler can not diagnose at compile time when such an already=20
>>    neutered object is used accidentally due to code rewrite etc.
>>    -=20
>>   =20
>>    Diagnostics and other interactions that are tied to the destruction=
=20
>>    occur far removed in time from the time the object actually falls out=
 of=20
>>    use.
>>   =20
>>
>> This proposal would allow for the following code:
>>
>> {
>>
>> auto file =3D file_open_rlock("data_snippet");
>>
>> auto blob =3D file.fetch_all();
>>
>> delete local file;
>>
>> auto conn =3D connect_to_peer("192.128.0.1");
>>
>> conn.send(blob);
>>
>> delete local blob;
>>
>> auto reply =3D conn.fetch_reply();
>>
>> delete local conn;
>>
>> auto file =3D file_create("output");
>>
>> file.write(reply);
>>
>> delete local file, reply;
>>
>> }
>>
>> Details
>>
>> Unlike the regular delete expression the argument is not a pointer but=
=20
>> rather a list of variable or function parameter names.
>>
>> Variables in the enclosing scope cannot be deleted from within selection=
=20
>> statements (if, switch), iteration statements (while, do, for), catch=20
>> clauses or other conditionally executed code.
>>
>> When goto crosses delete local in the direction of the program flow then=
=20
>> it deletes the object in the same way as when crossing =E2=80=9C}=E2=80=
=9D. When goto=20
>> passes delete local it must also pass the point of declaration of the=20
>> name.
>>
>> Optional: After delete local the name is free for reuse in a new=20
>> variable declaration.
>>
>>  --=20
>>
>> ---=20
>> You received this message because you are subscribed to the Google Group=
s=20
>> "ISO C++ Standard - Future Proposals" group.
>> To unsubscribe from this group and stop receiving emails from it, send a=
n=20
>> email to std-proposal...@isocpp.org <javascript:>.
>> To post to this group, send email to std-pr...@isocpp.org <javascript:>.
>> Visit this group at=20
>> http://groups.google.com/a/isocpp.org/group/std-proposals/.
>>
>
>

--=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/.

------=_Part_2498_80284596.1413364739294
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">I think the proposal addresses a number of drawbacks with =
that approach. I think that having a unified method to dispose of these obj=
ects without needing special support in your library has clear advantages.&=
nbsp;<div><br></div><div><div><div>Michael<br><br>On Wednesday, October 15,=
 2014 10:36:03 AM UTC+2, Andrew Tomazos wrote:<blockquote class=3D"gmail_qu=
ote" style=3D"margin: 0;margin-left: 0.8ex;border-left: 1px #ccc solid;padd=
ing-left: 1ex;"><div dir=3D"ltr">If your classes depend on destructor order=
ing, then you are doing too much in destructors, and are better off putting=
 the interesting part of the destructor into a member function and explicit=
ly calling it.&nbsp; In the destructor you can check if it has been called =
and then either error or call it automatically.&nbsp; The member function w=
ill have an expressive name that helps the reader understand what is going =
on, rather than hiding it in a nameless destructor.<div>&nbsp; -Andrew.</di=
v><div><br></div></div><div><br><div class=3D"gmail_quote">On Wed, Oct 15, =
2014 at 9:14 AM, Michael Bruck <span dir=3D"ltr">&lt;<a href=3D"javascript:=
" target=3D"_blank" gdf-obfuscated-mailto=3D"f8zSds6ejqUJ" onmousedown=3D"t=
his.href=3D'javascript:';return true;" onclick=3D"this.href=3D'javascript:'=
;return true;">bruck....@gmail.com</a>&gt;</span> wrote:<br><blockquote cla=
ss=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;pa=
dding-left:1ex"><div dir=3D"ltr"><span><p dir=3D"ltr" style=3D"line-height:=
1.15;margin-top:0pt;margin-bottom:0pt"><span style=3D"line-height:1.15">Hel=
lo everyone,</span><br></p><p dir=3D"ltr" style=3D"line-height:1.15;margin-=
top:0pt;margin-bottom:0pt"><br></p><p dir=3D"ltr" style=3D"line-height:1.15=
;margin-top:0pt;margin-bottom:0pt"><br></p><p dir=3D"ltr" style=3D"line-hei=
ght:1.15;margin-top:0pt;margin-bottom:0pt">I am looking for feedback on the=
 outline for a proposal below. I would like to know if there is interest in=
 such a feature and any ideas on improvements.</p><p dir=3D"ltr" style=3D"l=
ine-height:1.15;margin-top:0pt;margin-bottom:0pt"><br></p><p dir=3D"ltr" st=
yle=3D"line-height:1.15;margin-top:0pt;margin-bottom:0pt"><br></p><p dir=3D=
"ltr" style=3D"line-height:1.15;margin-top:0pt;margin-bottom:0pt"><br></p><=
p dir=3D"ltr" style=3D"line-height:1.15;margin-top:0pt;margin-bottom:0pt">R=
egards,</p><p dir=3D"ltr" style=3D"line-height:1.15;margin-top:0pt;margin-b=
ottom:0pt">Michael</p><p dir=3D"ltr" style=3D"line-height:1.15;margin-top:0=
pt;margin-bottom:0pt"><br></p><p dir=3D"ltr" style=3D"line-height:1.15;marg=
in-top:0pt;margin-bottom:0pt"><span style=3D"font-size:28px;font-family:'Tr=
ebuchet MS';color:rgb(0,0,0);white-space:pre-wrap;background-color:transpar=
ent"><br></span></p><p dir=3D"ltr" style=3D"line-height:1.15;margin-top:0pt=
;margin-bottom:0pt"><span style=3D"font-family:'Trebuchet MS';color:rgb(0,0=
,0);white-space:pre-wrap;background-color:transparent"><font size=3D"4">Del=
eting local variables</font></span></p><h1 dir=3D"ltr" style=3D"line-height=
:1.15;margin-top:10pt;margin-bottom:0pt"><span style=3D"font-family:'Trebuc=
het MS';color:rgb(0,0,0);white-space:pre-wrap;background-color:transparent"=
><font size=3D"4">Summary</font></span></h1><p dir=3D"ltr" style=3D"line-he=
ight:1.15;margin-top:0pt;margin-bottom:0pt"><span style=3D"font-size:15px;f=
ont-family:Arial;color:rgb(0,0,0);white-space:pre-wrap;background-color:tra=
nsparent">This proposal introduces a way to end the scope of a variable bef=
ore its enclosing block ends.</span></p><br><p dir=3D"ltr" style=3D"line-he=
ight:1.15;margin-top:0pt;margin-bottom:0pt"><span style=3D"font-size:15px;f=
ont-family:'Courier New';color:rgb(0,0,0);white-space:pre-wrap;background-c=
olor:transparent">{</span></p><p dir=3D"ltr" style=3D"line-height:1.15;marg=
in-top:0pt;margin-bottom:0pt;text-indent:36pt"><span style=3D"font-size:15p=
x;font-family:'Courier New';color:rgb(0,0,0);white-space:pre-wrap;backgroun=
d-color:transparent">std::string foo, bar;</span></p><p dir=3D"ltr" style=
=3D"line-height:1.15;margin-top:0pt;margin-bottom:0pt;text-indent:36pt"><sp=
an style=3D"font-size:15px;font-family:'Courier New';color:rgb(0,0,0);white=
-space:pre-wrap;background-color:transparent">...</span></p><p dir=3D"ltr" =
style=3D"line-height:1.15;margin-top:0pt;margin-bottom:0pt;text-indent:36pt=
"><span style=3D"font-size:15px;font-family:'Courier New';color:rgb(0,0,0);=
font-weight:bold;white-space:pre-wrap;background-color:transparent">delete<=
/span><span style=3D"font-size:15px;font-family:'Courier New';color:rgb(0,0=
,0);white-space:pre-wrap;background-color:transparent"> </span><span style=
=3D"font-size:15px;font-family:'Courier New';color:rgb(0,0,0);font-weight:b=
old;white-space:pre-wrap;background-color:transparent">local</span><span st=
yle=3D"font-size:15px;font-family:'Courier New';color:rgb(0,0,0);white-spac=
e:pre-wrap;background-color:transparent"> foo, bar;</span></p><p dir=3D"ltr=
" style=3D"line-height:1.15;margin-top:0pt;margin-bottom:0pt;text-indent:36=
pt"><span style=3D"font-size:15px;font-family:'Courier New';color:rgb(0,0,0=
);white-space:pre-wrap;background-color:transparent">...</span></p><p dir=
=3D"ltr" style=3D"line-height:1.15;margin-top:0pt;margin-bottom:0pt"><span =
style=3D"font-size:15px;font-family:'Courier New';color:rgb(0,0,0);white-sp=
ace:pre-wrap;background-color:transparent">}</span></p><br><h1 dir=3D"ltr" =
style=3D"line-height:1.15;margin-top:10pt;margin-bottom:0pt"><span style=3D=
"font-family:'Trebuchet MS';color:rgb(0,0,0);white-space:pre-wrap;backgroun=
d-color:transparent"><font size=3D"4">Motivation</font></span></h1><p dir=
=3D"ltr" style=3D"line-height:1.15;margin-top:0pt;margin-bottom:0pt"><span =
style=3D"font-size:15px;font-family:Arial;color:rgb(0,0,0);white-space:pre-=
wrap;background-color:transparent">The =E2=80=9C} operator=E2=80=9D is powe=
rful but but comes with a pre-defined destruction order which is not suitab=
le for all applications. In real world programs the desired scopes of objec=
ts are not always cleanly nested but sometimes overlap in complex ways.</sp=
an></p><p dir=3D"ltr" style=3D"line-height:1.15;margin-top:0pt;margin-botto=
m:0pt"><span style=3D"font-size:15px;font-family:Arial;color:rgb(0,0,0);whi=
te-space:pre-wrap;background-color:transparent">Sometimes objects hold expe=
nsive resources and especially with programming patterns like threading or =
resumable functions the resources can remain blocked long after use if othe=
r functions in the same block require a long time to complete.</span></p><b=
r><p dir=3D"ltr" style=3D"line-height:1.15;margin-top:0pt;margin-bottom:0pt=
"><span style=3D"font-size:15px;font-family:Arial;color:rgb(0,0,0);white-sp=
ace:pre-wrap;background-color:transparent">This leads to programming patter=
ns that try to mitigate this problem in suboptimal ways. A typical approach=
 looks like:</span></p><br><p dir=3D"ltr" style=3D"line-height:1.15;margin-=
top:0pt;margin-bottom:0pt"><span style=3D"font-size:15px;font-family:'Couri=
er New';color:rgb(0,0,0);white-space:pre-wrap;background-color:transparent"=
>{</span></p><p dir=3D"ltr" style=3D"line-height:1.15;margin-top:0pt;margin=
-bottom:0pt;text-indent:36pt"><span style=3D"font-size:15px;font-family:'Co=
urier New';color:rgb(0,0,0);white-space:pre-wrap;background-color:transpare=
nt">auto file =3D file_open_rlock("data_snippet"<wbr>);</span></p><p dir=3D=
"ltr" style=3D"line-height:1.15;margin-top:0pt;margin-bottom:0pt;text-inden=
t:36pt"><span style=3D"font-size:15px;font-family:'Courier New';color:rgb(0=
,0,0);white-space:pre-wrap;background-color:transparent">auto blob =3D file=
..fetch_all();</span></p><p dir=3D"ltr" style=3D"line-height:1.15;margin-top=
:0pt;margin-bottom:0pt;text-indent:36pt"><span style=3D"font-size:15px;font=
-family:'Courier New';color:rgb(0,0,0);white-space:pre-wrap;background-colo=
r:transparent">file.close();</span></p><br><p dir=3D"ltr" style=3D"line-hei=
ght:1.15;margin-top:0pt;margin-bottom:0pt;text-indent:36pt"><span style=3D"=
font-size:15px;font-family:'Courier New';color:rgb(0,0,0);white-space:pre-w=
rap;background-color:transparent">auto conn =3D connect_to_peer("192.128.0.=
1")<wbr>;</span></p><p dir=3D"ltr" style=3D"line-height:1.15;margin-top:0pt=
;margin-bottom:0pt;text-indent:36pt"><span style=3D"font-size:15px;font-fam=
ily:'Courier New';color:rgb(0,0,0);white-space:pre-wrap;background-color:tr=
ansparent">conn.send(blob);</span></p><p dir=3D"ltr" style=3D"line-height:1=
..15;margin-top:0pt;margin-bottom:0pt;text-indent:36pt"><span style=3D"font-=
size:15px;font-family:'Courier New';color:rgb(0,0,0);white-space:pre-wrap;b=
ackground-color:transparent">blob.destroy();</span></p><p dir=3D"ltr" style=
=3D"line-height:1.15;margin-top:0pt;margin-bottom:0pt;text-indent:36pt"><sp=
an style=3D"font-size:15px;font-family:'Courier New';color:rgb(0,0,0);white=
-space:pre-wrap;background-color:transparent">auto reply =3D conn.fetch_rep=
ly();</span></p><p dir=3D"ltr" style=3D"line-height:1.15;margin-top:0pt;mar=
gin-bottom:0pt;text-indent:36pt"><span style=3D"font-size:15px;font-family:=
'Courier New';color:rgb(0,0,0);white-space:pre-wrap;background-color:transp=
arent">conn.disconnect();</span></p><br><p dir=3D"ltr" style=3D"line-height=
:1.15;margin-top:0pt;margin-bottom:0pt;text-indent:36pt"><span style=3D"fon=
t-size:15px;font-family:'Courier New';color:rgb(0,0,0);white-space:pre-wrap=
;background-color:transparent">auto file2 =3D file_create("output");</span>=
</p><p dir=3D"ltr" style=3D"line-height:1.15;margin-top:0pt;margin-bottom:0=
pt;text-indent:36pt"><span style=3D"font-size:15px;font-family:'Courier New=
';color:rgb(0,0,0);white-space:pre-wrap;background-color:transparent">file2=
..write(reply);</span></p><p dir=3D"ltr" style=3D"line-height:1.15;margin-to=
p:0pt;margin-bottom:0pt;text-indent:36pt"><span style=3D"font-size:15px;fon=
t-family:'Courier New';color:rgb(0,0,0);white-space:pre-wrap;background-col=
or:transparent">reply.destroy();</span></p><p dir=3D"ltr" style=3D"line-hei=
ght:1.15;margin-top:0pt;margin-bottom:0pt;text-indent:36pt"><span style=3D"=
font-size:15px;font-family:'Courier New';color:rgb(0,0,0);white-space:pre-w=
rap;background-color:transparent">file2.close();</span></p><p dir=3D"ltr" s=
tyle=3D"line-height:1.15;margin-top:0pt;margin-bottom:0pt"><span style=3D"f=
ont-size:15px;font-family:'Courier New';color:rgb(0,0,0);white-space:pre-wr=
ap;background-color:transparent">}</span></p><br><p dir=3D"ltr" style=3D"li=
ne-height:1.15;margin-top:0pt;margin-bottom:0pt"><span style=3D"font-size:1=
5px;font-family:Arial;color:rgb(0,0,0);white-space:pre-wrap;background-colo=
r:transparent">There are a number of problems with this solution:</span></p=
><ul style=3D"margin-top:0pt;margin-bottom:0pt"><li dir=3D"ltr" style=3D"li=
st-style-type:disc;font-size:15px;font-family:Arial;color:rgb(0,0,0);vertic=
al-align:baseline;background-color:transparent"><p dir=3D"ltr" style=3D"lin=
e-height:1.15;margin-top:0pt;margin-bottom:0pt"><span style=3D"font-size:15=
px;white-space:pre-wrap;background-color:transparent">The library needs to =
provide a function that releases expensive resources in addition to the des=
tructor.</span></p></li><li dir=3D"ltr" style=3D"list-style-type:disc;font-=
size:15px;font-family:Arial;color:rgb(0,0,0);vertical-align:baseline;backgr=
ound-color:transparent"><p dir=3D"ltr" style=3D"line-height:1.15;margin-top=
:0pt;margin-bottom:0pt"><span style=3D"font-size:15px;white-space:pre-wrap;=
background-color:transparent">The library needs to keep track of the additi=
onal state in which resources are freed but the object not yet destroyed.</=
span></p></li><li dir=3D"ltr" style=3D"list-style-type:disc;font-size:15px;=
font-family:Arial;color:rgb(0,0,0);vertical-align:baseline;background-color=
:transparent"><p dir=3D"ltr" style=3D"line-height:1.15;margin-top:0pt;margi=
n-bottom:0pt"><span style=3D"font-size:15px;white-space:pre-wrap;background=
-color:transparent">The user needs to locate such a function and understand=
 its semantics to see if it really releases enough resources.</span></p></l=
i><li dir=3D"ltr" style=3D"list-style-type:disc;font-size:15px;font-family:=
Arial;color:rgb(0,0,0);vertical-align:baseline;background-color:transparent=
"><p dir=3D"ltr" style=3D"line-height:1.15;margin-top:0pt;margin-bottom:0pt=
"><span style=3D"font-size:15px;white-space:pre-wrap;background-color:trans=
parent">The neutered object still lingers in some form on the stack until t=
he end of the scope.</span></p></li><li dir=3D"ltr" style=3D"list-style-typ=
e:disc;font-size:15px;font-family:Arial;color:rgb(0,0,0);vertical-align:bas=
eline;background-color:transparent"><p dir=3D"ltr" style=3D"line-height:1.1=
5;margin-top:0pt;margin-bottom:0pt"><span style=3D"font-size:15px;white-spa=
ce:pre-wrap;background-color:transparent">The compiler can not diagnose at =
compile time when such an already neutered object is used accidentally due =
to code rewrite etc.</span></p></li><li dir=3D"ltr" style=3D"list-style-typ=
e:disc;font-size:15px;font-family:Arial;color:rgb(0,0,0);vertical-align:bas=
eline;background-color:transparent"><p dir=3D"ltr" style=3D"line-height:1.1=
5;margin-top:0pt;margin-bottom:0pt"><span style=3D"font-size:15px;white-spa=
ce:pre-wrap;background-color:transparent">Diagnostics and other interaction=
s that are tied to the destruction occur far removed in time from the time =
the object actually falls out of use.</span></p></li></ul><br><p dir=3D"ltr=
" style=3D"line-height:1.15;margin-top:0pt;margin-bottom:0pt"><span style=
=3D"font-size:15px;font-family:Arial;color:rgb(0,0,0);white-space:pre-wrap;=
background-color:transparent">This proposal would allow for the following c=
ode:</span></p><p dir=3D"ltr" style=3D"line-height:1.15;margin-top:0pt;marg=
in-bottom:0pt"><span style=3D"font-size:15px;font-family:'Courier New';colo=
r:rgb(0,0,0);white-space:pre-wrap;background-color:transparent">{</span></p=
><p dir=3D"ltr" style=3D"line-height:1.15;margin-top:0pt;margin-bottom:0pt;=
text-indent:36pt"><span style=3D"font-size:15px;font-family:'Courier New';c=
olor:rgb(0,0,0);white-space:pre-wrap;background-color:transparent">auto fil=
e =3D file_open_rlock("data_snippet"<wbr>);</span></p><p dir=3D"ltr" style=
=3D"line-height:1.15;margin-top:0pt;margin-bottom:0pt;text-indent:36pt"><sp=
an style=3D"font-size:15px;font-family:'Courier New';color:rgb(0,0,0);white=
-space:pre-wrap;background-color:transparent">auto blob =3D file.fetch_all(=
);</span></p><p dir=3D"ltr" style=3D"line-height:1.15;margin-top:0pt;margin=
-bottom:0pt;text-indent:36pt"><span style=3D"font-size:15px;font-family:'Co=
urier New';color:rgb(0,0,0);font-weight:bold;white-space:pre-wrap;backgroun=
d-color:transparent">delete local file;</span></p><br><p dir=3D"ltr" style=
=3D"line-height:1.15;margin-top:0pt;margin-bottom:0pt;text-indent:36pt"><sp=
an style=3D"font-size:15px;font-family:'Courier New';color:rgb(0,0,0);white=
-space:pre-wrap;background-color:transparent">auto conn =3D connect_to_peer=
("192.128.0.1")<wbr>;</span></p><p dir=3D"ltr" style=3D"line-height:1.15;ma=
rgin-top:0pt;margin-bottom:0pt;text-indent:36pt"><span style=3D"font-size:1=
5px;font-family:'Courier New';color:rgb(0,0,0);white-space:pre-wrap;backgro=
und-color:transparent">conn.send(blob);</span></p><p dir=3D"ltr" style=3D"l=
ine-height:1.15;margin-top:0pt;margin-bottom:0pt;text-indent:36pt"><span st=
yle=3D"font-size:15px;font-family:'Courier New';color:rgb(0,0,0);font-weigh=
t:bold;white-space:pre-wrap;background-color:transparent">delete local blob=
;</span></p><p dir=3D"ltr" style=3D"line-height:1.15;margin-top:0pt;margin-=
bottom:0pt;text-indent:36pt"><span style=3D"font-size:15px;font-family:'Cou=
rier New';color:rgb(0,0,0);white-space:pre-wrap;background-color:transparen=
t">auto reply =3D conn.fetch_reply();</span></p><p dir=3D"ltr" style=3D"lin=
e-height:1.15;margin-top:0pt;margin-bottom:0pt;text-indent:36pt"><span styl=
e=3D"font-size:15px;font-family:'Courier New';color:rgb(0,0,0);font-weight:=
bold;white-space:pre-wrap;background-color:transparent">delete local conn;<=
/span></p><br><p dir=3D"ltr" style=3D"line-height:1.15;margin-top:0pt;margi=
n-bottom:0pt;text-indent:36pt"><span style=3D"font-size:15px;font-family:'C=
ourier New';color:rgb(0,0,0);white-space:pre-wrap;background-color:transpar=
ent">auto file =3D file_create("output");</span></p><p dir=3D"ltr" style=3D=
"line-height:1.15;margin-top:0pt;margin-bottom:0pt;text-indent:36pt"><span =
style=3D"font-size:15px;font-family:'Courier New';color:rgb(0,0,0);white-sp=
ace:pre-wrap;background-color:transparent">file.write(reply);</span></p><p =
dir=3D"ltr" style=3D"line-height:1.15;margin-top:0pt;margin-bottom:0pt;text=
-indent:36pt"><span style=3D"font-size:15px;font-family:'Courier New';color=
:rgb(0,0,0);font-weight:bold;white-space:pre-wrap;background-color:transpar=
ent">delete local file, reply;</span></p><p dir=3D"ltr" style=3D"line-heigh=
t:1.15;margin-top:0pt;margin-bottom:0pt"><span style=3D"font-size:15px;font=
-family:'Courier New';color:rgb(0,0,0);white-space:pre-wrap;background-colo=
r:transparent">}</span></p><br><h1 dir=3D"ltr" style=3D"line-height:1.15;ma=
rgin-top:10pt;margin-bottom:0pt"><span style=3D"font-family:'Trebuchet MS';=
color:rgb(0,0,0);white-space:pre-wrap;background-color:transparent"><font s=
ize=3D"4">Details</font></span></h1><br><p dir=3D"ltr" style=3D"line-height=
:1.15;margin-top:0pt;margin-bottom:0pt"><span style=3D"font-size:15px;font-=
family:Arial;color:rgb(0,0,0);white-space:pre-wrap;background-color:transpa=
rent">Unlike the regular </span><span style=3D"font-size:15px;font-family:'=
Courier New';color:rgb(0,0,0);white-space:pre-wrap;background-color:transpa=
rent">delete</span><span style=3D"font-size:15px;font-family:Arial;color:rg=
b(0,0,0);white-space:pre-wrap;background-color:transparent"> expression the=
 argument is not a pointer but rather a list of variable or function parame=
ter names.</span></p><br><p dir=3D"ltr" style=3D"line-height:1.15;margin-to=
p:0pt;margin-bottom:0pt"><span style=3D"font-size:15px;font-family:Arial;co=
lor:rgb(0,0,0);white-space:pre-wrap;background-color:transparent">Variables=
 in the enclosing scope cannot be deleted from within selection statements =
(</span><span style=3D"font-size:15px;font-family:'Courier New';color:rgb(0=
,0,0);white-space:pre-wrap;background-color:transparent">if</span><span sty=
le=3D"font-size:15px;font-family:Arial;color:rgb(0,0,0);white-space:pre-wra=
p;background-color:transparent">, </span><span style=3D"font-size:15px;font=
-family:'Courier New';color:rgb(0,0,0);white-space:pre-wrap;background-colo=
r:transparent">switch</span><span style=3D"font-size:15px;font-family:Arial=
;color:rgb(0,0,0);white-space:pre-wrap;background-color:transparent">), ite=
ration statements (</span><span style=3D"font-size:15px;font-family:'Courie=
r New';color:rgb(0,0,0);white-space:pre-wrap;background-color:transparent">=
while</span><span style=3D"font-size:15px;font-family:Arial;color:rgb(0,0,0=
);white-space:pre-wrap;background-color:transparent">, </span><span style=
=3D"font-size:15px;font-family:'Courier New';color:rgb(0,0,0);white-space:p=
re-wrap;background-color:transparent">do</span><span style=3D"font-size:15p=
x;font-family:Arial;color:rgb(0,0,0);white-space:pre-wrap;background-color:=
transparent">, </span><span style=3D"font-size:15px;font-family:'Courier Ne=
w';color:rgb(0,0,0);white-space:pre-wrap;background-color:transparent">for<=
/span><span style=3D"font-size:15px;font-family:Arial;color:rgb(0,0,0);whit=
e-space:pre-wrap;background-color:transparent">), </span><span style=3D"fon=
t-size:15px;font-family:'Courier New';color:rgb(0,0,0);white-space:pre-wrap=
;background-color:transparent">catch</span><span style=3D"font-size:15px;fo=
nt-family:Arial;color:rgb(0,0,0);white-space:pre-wrap;background-color:tran=
sparent"> clauses or other conditionally executed code.</span></p><br><p di=
r=3D"ltr" style=3D"line-height:1.15;margin-top:0pt;margin-bottom:0pt"><span=
 style=3D"font-size:15px;font-family:Arial;color:rgb(0,0,0);white-space:pre=
-wrap;background-color:transparent">When </span><span style=3D"font-size:15=
px;font-family:'Courier New';color:rgb(0,0,0);white-space:pre-wrap;backgrou=
nd-color:transparent">goto</span><span style=3D"font-size:15px;font-family:=
Arial;color:rgb(0,0,0);white-space:pre-wrap;background-color:transparent"> =
crosses </span><span style=3D"font-size:15px;font-family:'Courier New';colo=
r:rgb(0,0,0);white-space:pre-wrap;background-color:transparent">delete loca=
l</span><span style=3D"font-size:15px;font-family:Arial;color:rgb(0,0,0);wh=
ite-space:pre-wrap;background-color:transparent"> in the direction of the p=
rogram flow then it deletes the object in the same way as when crossing =E2=
=80=9C}=E2=80=9D. When </span><span style=3D"font-size:15px;font-family:'Co=
urier New';color:rgb(0,0,0);white-space:pre-wrap;background-color:transpare=
nt">goto</span><span style=3D"font-size:15px;font-family:Arial;color:rgb(0,=
0,0);white-space:pre-wrap;background-color:transparent"> passes </span><spa=
n style=3D"font-size:15px;font-family:'Courier New';color:rgb(0,0,0);white-=
space:pre-wrap;background-color:transparent">delete local</span><span style=
=3D"font-size:15px;font-family:Arial;color:rgb(0,0,0);white-space:pre-wrap;=
background-color:transparent"> it must also pass the point of declaration o=
f the name.</span></p><br><p dir=3D"ltr" style=3D"line-height:1.15;margin-t=
op:0pt;margin-bottom:0pt"><span style=3D"font-size:15px;font-family:Arial;c=
olor:rgb(0,0,0);white-space:pre-wrap;background-color:transparent">Optional=
: After </span><span style=3D"font-size:15px;font-family:'Courier New';colo=
r:rgb(0,0,0);white-space:pre-wrap;background-color:transparent">delete loca=
l</span><span style=3D"font-size:15px;font-family:Arial;color:rgb(0,0,0);wh=
ite-space:pre-wrap;background-color:transparent"> the name is free for reus=
e in a new variable declaration.</span></p><span><font color=3D"#888888"><h=
1 dir=3D"ltr" style=3D"line-height:1.15;margin-top:10pt;margin-bottom:0pt">=
<br></h1></font></span></span></div><span><font color=3D"#888888">

<p></p>

-- <br>
<br>
--- <br>
You received this message because you are subscribed to the Google Groups "=
ISO C++ Standard - Future Proposals" group.<br>
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"javascript:" target=3D"_blank" gdf-obfuscated-mailto=3D"=
f8zSds6ejqUJ" onmousedown=3D"this.href=3D'javascript:';return true;" onclic=
k=3D"this.href=3D'javascript:';return true;">std-proposal...@<wbr>isocpp.or=
g</a>.<br>
To post to this group, send email to <a href=3D"javascript:" target=3D"_bla=
nk" gdf-obfuscated-mailto=3D"f8zSds6ejqUJ" onmousedown=3D"this.href=3D'java=
script:';return true;" onclick=3D"this.href=3D'javascript:';return true;">s=
td-pr...@isocpp.org</a>.<br>
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/" target=3D"_blank" onmousedown=3D"this.href=3D'http://groups=
..google.com/a/isocpp.org/group/std-proposals/';return true;" onclick=3D"thi=
s.href=3D'http://groups.google.com/a/isocpp.org/group/std-proposals/';retur=
n true;">http://groups.google.com/a/<wbr>isocpp.org/group/std-<wbr>proposal=
s/</a>.<br>
</font></span></blockquote></div><br></div>
</blockquote></div></div></div></div>

<p></p>

-- <br />
<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 <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 />
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/">http://groups.google.com/a/isocpp.org/group/std-proposals/<=
/a>.<br />

------=_Part_2498_80284596.1413364739294--

.
