Topic: Proposal for a delete expression for local variables
Author: Michael Bruck <bruck.michael@gmail.com>
Date: Wed, 15 Oct 2014 00:14:42 -0700 (PDT)
Raw View
------=_Part_5096_541171398.1413357282489
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
Hello everyone,
I am looking for feedback on the outline for a proposal below. I would like=
=20
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-defin=
ed 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 sometimes=
=20
overlap in complex ways.
Sometimes objects hold expensive resources and especially with programming=
=20
patterns like threading or resumable functions the resources can remain=20
blocked long after use if other functions in the same block require a long=
=20
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 to=
=20
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 it=
=20
deletes the object in the same way as when crossing =E2=80=9C}=E2=80=9D. Wh=
en goto passes delete=20
local it must also pass the point of declaration of the name.
Optional: After delete local the name is free for reuse in a new variable=
=20
declaration.
--=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_5096_541171398.1413357282489
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr"><span id=3D"docs-internal-guid-bea6027e-129f-b3ae-8479-c2b=
829f4a73d"><p dir=3D"ltr" style=3D"line-height:1.15;margin-top:0pt;margin-b=
ottom:0pt;"><span style=3D"line-height: 1.15;">Hello 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-b=
ottom:0pt;"><br></p><p dir=3D"ltr" style=3D"line-height:1.15;margin-top:0pt=
;margin-bottom:0pt;">I am looking for feedback on the outline for a proposa=
l below. I would like to know if there is interest in such a feature and an=
y ideas on improvements.</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-=
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;">Regards,</p><p dir=
=3D"ltr" style=3D"line-height:1.15;margin-top:0pt;margin-bottom:0pt;">Micha=
el</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;marg=
in-bottom:0pt;"><span style=3D"font-size: 28px; font-family: 'Trebuchet MS'=
; color: rgb(0, 0, 0); white-space: pre-wrap; background-color: transparent=
;"><br></span></p><p dir=3D"ltr" style=3D"line-height:1.15;margin-top:0pt;m=
argin-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">Deleting local variables</font></span></p><h1 dir=3D"ltr" style=3D"l=
ine-height:1.15;margin-top:10pt;margin-bottom:0pt;"><span style=3D"font-fam=
ily: 'Trebuchet 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-height:1.15;margin-top:0pt;margin-bottom:0pt;"><span sty=
le=3D"font-size: 15px; font-family: Arial; color: rgb(0, 0, 0); white-space=
: pre-wrap; background-color: transparent;">This proposal introduces a way =
to end the scope of a variable before its enclosing block ends.</span></p><=
br><p dir=3D"ltr" style=3D"line-height:1.15;margin-top:0pt;margin-bottom:0p=
t;"><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=
;text-indent: 36pt;"><span style=3D"font-size: 15px; font-family: 'Courier =
New'; color: rgb(0, 0, 0); white-space: pre-wrap; background-color: transpa=
rent;">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;"><span style=3D"fo=
nt-size: 15px; font-family: 'Courier New'; color: rgb(0, 0, 0); white-space=
: pre-wrap; background-color: transparent;">...</span></p><p dir=3D"ltr" st=
yle=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: transpa=
rent;">delete</span><span style=3D"font-size: 15px; font-family: 'Courier N=
ew'; color: rgb(0, 0, 0); white-space: pre-wrap; background-color: transpar=
ent;"> </span><span style=3D"font-size: 15px; font-family: 'Courier New'; c=
olor: rgb(0, 0, 0); font-weight: bold; white-space: pre-wrap; background-co=
lor: transparent;">local</span><span style=3D"font-size: 15px; font-family:=
'Courier New'; color: rgb(0, 0, 0); white-space: pre-wrap; background-colo=
r: transparent;"> foo, bar;</span></p><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;">...</span></p><p dir=3D"ltr" sty=
le=3D"line-height:1.15;margin-top:0pt;margin-bottom:0pt;"><span style=3D"fo=
nt-size: 15px; font-family: 'Courier New'; color: rgb(0, 0, 0); white-space=
: 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=
; background-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} o=
perator=E2=80=9D is powerful but but comes with a pre-defined destruction o=
rder which is not suitable for all applications. In real world programs the=
desired scopes of objects are not always cleanly nested but sometimes over=
lap in complex ways.</span></p><p dir=3D"ltr" style=3D"line-height:1.15;mar=
gin-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: tran=
sparent;">Sometimes objects hold expensive resources and especially with pr=
ogramming patterns like threading or resumable functions the resources can =
remain blocked long after use if other functions in the same block require =
a long time to complete.</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; fon=
t-family: Arial; color: rgb(0, 0, 0); white-space: pre-wrap; background-col=
or: transparent;">This leads to programming patterns that try to mitigate t=
his problem in suboptimal ways. A typical approach looks like:</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: '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 N=
ew'; color: rgb(0, 0, 0); white-space: pre-wrap; background-color: transpar=
ent;">auto file =3D file_open_rlock("data_snippet");</span></p><p dir=3D"lt=
r" 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: r=
gb(0, 0, 0); white-space: pre-wrap; background-color: transparent;">auto bl=
ob =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-s=
ize: 15px; font-family: 'Courier New'; color: rgb(0, 0, 0); white-space: pr=
e-wrap; background-color: transparent;">file.close();</span></p><br><p dir=
=3D"ltr" style=3D"line-height:1.15;margin-top:0pt;margin-bottom:0pt;text-in=
dent: 36pt;"><span style=3D"font-size: 15px; font-family: 'Courier New'; co=
lor: rgb(0, 0, 0); white-space: pre-wrap; background-color: transparent;">a=
uto conn =3D connect_to_peer("192.128.0.1");</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-color: transparent;">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; background-colo=
r: transparent;">blob.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-wrap; background-color: transparent;">auto reply =3D conn.fetch=
_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); white-space: pre-wrap; backgro=
und-color: transparent;">conn.disconnect();</span></p><br><p dir=3D"ltr" st=
yle=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-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: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: transparent;">file2.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); white-space: pre-wrap; background-color: transparent;=
">reply.destroy();</span></p><p dir=3D"ltr" style=3D"line-height:1.15;margi=
n-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=
; 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"=
font-size: 15px; font-family: 'Courier New'; color: rgb(0, 0, 0); white-spa=
ce: pre-wrap; background-color: transparent;">}</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: Arial; color: rgb(0, 0, 0); white-space: =
pre-wrap; background-color: transparent;">There are a number of problems wi=
th this solution:</span></p><ul style=3D"margin-top:0pt;margin-bottom:0pt;"=
><li dir=3D"ltr" style=3D"list-style-type: disc; font-size: 15px; font-fami=
ly: 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;marg=
in-bottom:0pt;"><span style=3D"font-size: 15px; white-space: pre-wrap; back=
ground-color: transparent;">The library needs to provide a function that re=
leases expensive resources in addition to the destructor.</span></p></li><l=
i 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: tr=
ansparent;"><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; backgro=
und-color: transparent;">The library needs to keep track of the additional =
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; f=
ont-family: Arial; color: rgb(0, 0, 0); vertical-align: baseline; backgroun=
d-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-wr=
ap; background-color: transparent;">The user needs to locate such a functio=
n and understand its semantics to see if it really releases enough resource=
s.</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;ma=
rgin-top:0pt;margin-bottom:0pt;"><span style=3D"font-size: 15px; white-spac=
e: pre-wrap; background-color: transparent;">The neutered object still ling=
ers in some form on the stack until the end of the scope.</span></p></li><l=
i 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: tr=
ansparent;"><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; backgro=
und-color: transparent;">The compiler can not diagnose at compile time when=
such an already neutered object is used accidentally due to code rewrite e=
tc.</span></p></li><li dir=3D"ltr" style=3D"list-style-type: disc; font-siz=
e: 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;m=
argin-top:0pt;margin-bottom:0pt;"><span style=3D"font-size: 15px; white-spa=
ce: pre-wrap; background-color: transparent;">Diagnostics and other interac=
tions that are tied to the destruction occur far removed in time from the t=
ime 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 st=
yle=3D"font-size: 15px; font-family: Arial; color: rgb(0, 0, 0); white-spac=
e: pre-wrap; background-color: transparent;">This proposal would allow for =
the following code:</span></p><p dir=3D"ltr" style=3D"line-height:1.15;marg=
in-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><p dir=3D"ltr" style=3D"line-height:1.15;margi=
n-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=
; background-color: transparent;">auto file =3D file_open_rlock("data_snipp=
et");</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-fam=
ily: '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"lt=
r" 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: r=
gb(0, 0, 0); font-weight: bold; white-space: pre-wrap; background-color: tr=
ansparent;">delete local file;</span></p><br><p dir=3D"ltr" style=3D"line-h=
eight: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-color: transparent;">auto conn =3D connect_to_=
peer("192.128.0.1");</span></p><p dir=3D"ltr" style=3D"line-height:1.15;mar=
gin-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-wr=
ap; background-color: transparent;">conn.send(blob);</span></p><p dir=3D"lt=
r" 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: r=
gb(0, 0, 0); font-weight: bold; white-space: pre-wrap; background-color: tr=
ansparent;">delete local blob;</span></p><p dir=3D"ltr" style=3D"line-heigh=
t: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-spa=
ce: 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-fam=
ily: 'Courier New'; color: rgb(0, 0, 0); font-weight: bold; white-space: pr=
e-wrap; background-color: transparent;">delete local conn;</span></p><br><p=
dir=3D"ltr" style=3D"line-height:1.15;margin-top:0pt;margin-bottom:0pt;tex=
t-indent: 36pt;"><span style=3D"font-size: 15px; font-family: 'Courier New'=
; color: rgb(0, 0, 0); white-space: pre-wrap; background-color: transparent=
;">auto file =3D file_create("output");</span></p><p dir=3D"ltr" style=3D"l=
ine-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-color: transparent;">file.write(reply);</=
span></p><p dir=3D"ltr" style=3D"line-height:1.15;margin-top:0pt;margin-bot=
tom:0pt;text-indent: 36pt;"><span style=3D"font-size: 15px; font-family: 'C=
ourier New'; color: rgb(0, 0, 0); font-weight: bold; white-space: pre-wrap;=
background-color: transparent;">delete local file, reply;</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-space: 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-spac=
e: pre-wrap; background-color: transparent;"><font size=3D"4">Details</font=
></span></h1><br><p dir=3D"ltr" style=3D"line-height:1.15;margin-top:0pt;ma=
rgin-bottom:0pt;"><span style=3D"font-size: 15px; font-family: Arial; color=
: rgb(0, 0, 0); white-space: pre-wrap; background-color: transparent;">Unli=
ke the regular </span><span style=3D"font-size: 15px; font-family: 'Courier=
New'; color: rgb(0, 0, 0); white-space: pre-wrap; background-color: transp=
arent;">delete</span><span style=3D"font-size: 15px; font-family: Arial; co=
lor: rgb(0, 0, 0); white-space: pre-wrap; background-color: transparent;"> =
expression the argument is not a pointer but rather a list of variable or f=
unction parameter names.</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; fon=
t-family: Arial; color: rgb(0, 0, 0); white-space: pre-wrap; background-col=
or: transparent;">Variables in the enclosing scope cannot be deleted from w=
ithin selection statements (</span><span style=3D"font-size: 15px; font-fam=
ily: 'Courier New'; color: rgb(0, 0, 0); white-space: pre-wrap; background-=
color: transparent;">if</span><span style=3D"font-size: 15px; font-family: =
Arial; color: rgb(0, 0, 0); white-space: pre-wrap; background-color: transp=
arent;">, </span><span style=3D"font-size: 15px; font-family: 'Courier New'=
; color: rgb(0, 0, 0); white-space: pre-wrap; background-color: 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: 'Cou=
rier New'; color: rgb(0, 0, 0); white-space: pre-wrap; background-color: tr=
ansparent;">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'; colo=
r: rgb(0, 0, 0); white-space: pre-wrap; background-color: transparent;">do<=
/span><span style=3D"font-size: 15px; font-family: Arial; color: rgb(0, 0, =
0); white-space: pre-wrap; background-color: transparent;">, </span><span s=
tyle=3D"font-size: 15px; font-family: 'Courier New'; color: rgb(0, 0, 0); w=
hite-space: pre-wrap; background-color: transparent;">for</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-siz=
e: 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; font-family: Arial; color: rgb(0, 0, 0); white-space: pre-wrap; back=
ground-color: transparent;"> clauses or other conditionally executed code.<=
/span></p><br><p dir=3D"ltr" style=3D"line-height:1.15;margin-top:0pt;margi=
n-bottom:0pt;"><span style=3D"font-size: 15px; font-family: Arial; color: r=
gb(0, 0, 0); white-space: pre-wrap; background-color: transparent;">When </=
span><span style=3D"font-size: 15px; font-family: 'Courier New'; color: rgb=
(0, 0, 0); white-space: pre-wrap; background-color: transparent;">goto</spa=
n><span style=3D"font-size: 15px; font-family: Arial; color: rgb(0, 0, 0); =
white-space: pre-wrap; background-color: transparent;"> crosses </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); w=
hite-space: pre-wrap; background-color: transparent;"> in the direction of =
the program flow then it deletes the object in the same way as when crossin=
g =E2=80=9C}=E2=80=9D. When </span><span style=3D"font-size: 15px; font-fam=
ily: 'Courier New'; color: rgb(0, 0, 0); white-space: pre-wrap; background-=
color: transparent;">goto</span><span style=3D"font-size: 15px; font-family=
: Arial; color: rgb(0, 0, 0); white-space: pre-wrap; background-color: tran=
sparent;"> passes </span><span style=3D"font-size: 15px; font-family: 'Cour=
ier New'; color: rgb(0, 0, 0); white-space: pre-wrap; background-color: tra=
nsparent;">delete local</span><span style=3D"font-size: 15px; font-family: =
Arial; color: rgb(0, 0, 0); white-space: pre-wrap; background-color: transp=
arent;"> it must also pass the point of declaration of the name.</span></p>=
<br><p dir=3D"ltr" style=3D"line-height:1.15;margin-top:0pt;margin-bottom:0=
pt;"><span style=3D"font-size: 15px; font-family: Arial; color: rgb(0, 0, 0=
); white-space: pre-wrap; background-color: transparent;">Optional: After <=
/span><span style=3D"font-size: 15px; font-family: 'Courier New'; color: rg=
b(0, 0, 0); white-space: pre-wrap; background-color: transparent;">delete l=
ocal</span><span style=3D"font-size: 15px; font-family: Arial; color: rgb(0=
, 0, 0); white-space: pre-wrap; background-color: transparent;"> the name i=
s free for reuse in a new variable declaration.</span></p><h1 dir=3D"ltr" s=
tyle=3D"line-height:1.15;margin-top:10pt;margin-bottom:0pt;"><br></h1></spa=
n></div>
<p></p>
-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;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"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_5096_541171398.1413357282489--
.
Author: Markus Grech <markus.grech@gmail.com>
Date: Wed, 15 Oct 2014 00:33:02 -0700 (PDT)
Raw View
------=_Part_4817_2045661620.1413358382025
Content-Type: text/plain; charset=UTF-8
Why not just limit the scope by adding an additional pair of {}? Is there
any advantage to using "delete local"?
--
---
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/.
------=_Part_4817_2045661620.1413358382025
Content-Type: text/html; charset=UTF-8
<div dir="ltr">Why not just limit the scope by adding an additional pair of {}? Is there any advantage to using "delete local"?</div>
<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 email to <a href="mailto:std-proposals+unsubscribe@isocpp.org">std-proposals+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href="mailto:std-proposals@isocpp.org">std-proposals@isocpp.org</a>.<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 />
------=_Part_4817_2045661620.1413358382025--
.
Author: Michael Bruck <bruck.michael@gmail.com>
Date: Wed, 15 Oct 2014 01:23:40 -0700 (PDT)
Raw View
------=_Part_5235_252979900.1413361420406
Content-Type: text/plain; charset=UTF-8
On Wednesday, October 15, 2014 9:33:02 AM UTC+2, Markus Grech wrote:
>
> Why not just limit the scope by adding an additional pair of {}? Is there
> any advantage to using "delete local"?
>
With {} you lose the use of auto and your code becomes a bit more verbose.
Later modifications become a nightmare. And you need the additional state
'constructed but not yet initialized'.
I hope I got it right:
{
some_typename_we_never_wanted_to_type_again1 reply;
{
some_typename_we_never_wanted_to_type_again2 conn;
{
some_typename_we_never_wanted_to_type_again3 blob;
{
auto file = file_open_rlock("data_snippet");
blob = file.fetch_all();
}
conn = connect_to_peer("192.128.0.1");
conn.send(blob);
}
reply = conn.fetch_reply();
}
{
auto file = file_create("output");
file.write(reply);
}
}
--
---
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/.
------=_Part_5235_252979900.1413361420406
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr"><br><br>On Wednesday, October 15, 2014 9:33:02 AM UTC+2, M=
arkus Grech wrote:<blockquote class=3D"gmail_quote" style=3D"margin: 0;marg=
in-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><div dir=3D"=
ltr">Why not just limit the scope by adding an additional pair of {}? Is th=
ere any advantage to using "delete local"?</div></blockquote><div><br></div=
><div>With {} you lose the use of auto and your code becomes a bit more ver=
bose. Later modifications become a nightmare. And you need the additional s=
tate 'constructed but not yet initialized'.</div><div><br></div><div>I hope=
I got it right:</div><div><br></div><div><div>{</div><div> so=
me_typename_we_never_wanted_to_type_again1 reply;</div><div><br></div><div>=
{</div><div><span class=3D"Apple-tab-span" style=3D"white-spa=
ce:pre"> </span>some_typename_we_never_wanted_to_type_again2 conn;</div><di=
v><br></div><div><span class=3D"Apple-tab-span" style=3D"white-space:pre"> =
</span>{</div><div><span class=3D"Apple-tab-span" style=3D"white-space:pre"=
> </span> some_typename_we_never_wanted_to_type_again3 blob;</=
div><div><br></div><div><span class=3D"Apple-tab-span" style=3D"white-space=
:pre"> </span> {</div><div><span class=3D"Apple-tab-span" styl=
e=3D"white-space:pre"> </span>auto file =3D file_open_rlock("data_snippet"=
);</div><div><span class=3D"Apple-tab-span" style=3D"white-space:pre"> </s=
pan>blob =3D file.fetch_all();</div><div><span class=3D"Apple-tab-span" sty=
le=3D"white-space:pre"> </span> }</div><div><br></div><div><sp=
an class=3D"Apple-tab-span" style=3D"white-space:pre"> </span>  =
;conn =3D connect_to_peer("192.128.0.1");</div><div><span class=3D"Apple-ta=
b-span" style=3D"white-space:pre"> </span> conn.send(blob);</d=
iv><div><span class=3D"Apple-tab-span" style=3D"white-space:pre"> </span>}<=
/div><div><span class=3D"Apple-tab-span" style=3D"white-space:pre"> </span>=
reply =3D conn.fetch_reply();</div><div> }</div><div><br></div=
><div> {</div><div><span class=3D"Apple-tab-span" style=3D"whi=
te-space:pre"> </span>auto file =3D file_create("output");</div><div><span =
class=3D"Apple-tab-span" style=3D"white-space:pre"> </span>file.write(reply=
);</div><div> }</div><div>}</div></div><div><br></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" 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_5235_252979900.1413361420406--
.
Author: Roman Perepelitsa <roman.perepelitsa@gmail.com>
Date: Wed, 15 Oct 2014 10:33:03 +0200
Raw View
--047d7b342c90287abe050571fc32
Content-Type: text/plain; charset=UTF-8
2014-10-15 9:33 GMT+02:00 Markus Grech <markus.grech@gmail.com>:
> Why not just limit the scope by adding an additional pair of {}? Is there
> any advantage to using "delete local"?
>
The "delete local" construct, unlike an extra pair of {}, works with
function parameters.
void foo(std::string s)
{
bar(std::move(s));
// Make sure we don't use 's' after it's been moved.
// Free resources if it still has any.
delete local s;
...
}
Roman Perepelitsa.
--
---
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/.
--047d7b342c90287abe050571fc32
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr"><div class=3D"gmail_extra"><div class=3D"gmail_quote">2014=
-10-15 9:33 GMT+02:00 Markus Grech <span dir=3D"ltr"><<a href=3D"mailto:=
markus.grech@gmail.com" target=3D"_blank">markus.grech@gmail.com</a>></s=
pan>:<br><blockquote class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8e=
x;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-styl=
e:solid;padding-left:1ex"><div dir=3D"ltr">Why not just limit the scope by =
adding an additional pair of {}? Is there any advantage to using "dele=
te local"?</div></blockquote><div><br></div><div>The "delete loca=
l" construct, unlike an extra pair of {}, works with function paramete=
rs.</div><div><br></div><div><font face=3D"courier new, monospace">=C2=A0 v=
oid foo(std::string s)</font></div><div><font face=3D"courier new, monospac=
e">=C2=A0 {</font></div><div><font face=3D"courier new, monospace">=C2=A0 =
=C2=A0 bar(std::move(s));</font></div><div><font face=3D"courier new, monos=
pace">=C2=A0 =C2=A0 // Make sure we don't use 's' after it'=
s been moved.</font></div><div><font face=3D"courier new, monospace">=C2=A0=
=C2=A0 // Free resources if it still has any.</font></div><div><font face=
=3D"courier new, monospace">=C2=A0 =C2=A0 delete local s;</font></div><div>=
<font face=3D"courier new, monospace">=C2=A0 =C2=A0 ...</font></div><div><f=
ont face=3D"courier new, monospace">=C2=A0 }</font></div><div><br></div><di=
v>Roman Perepelitsa.</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" 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 />
--047d7b342c90287abe050571fc32--
.
Author: Andrew Tomazos <andrewtomazos@gmail.com>
Date: Wed, 15 Oct 2014 10:36:00 +0200
Raw View
--001a1132f53e7f28d7050572057c
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
If your classes depend on destructor ordering, then you are doing too much
in destructors, and are better off putting the interesting part of the
destructor into a member function and explicitly calling it. In the
destructor you can check if it has been called and then either error or
call it automatically. The member function will have an expressive name
that helps the reader understand what is going on, rather than hiding it in
a nameless destructor.
-Andrew.
On Wed, Oct 15, 2014 at 9:14 AM, Michael Bruck <bruck.michael@gmail.com>
wrote:
> Hello everyone,
>
>
>
> 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.
>
>
>
>
> Regards,
>
> Michael
>
>
>
> Deleting local variables
> Summary
>
> This proposal introduces a way to end the scope of a variable before its
> 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-def=
ined destruction
> order which is not suitable for all applications. In real world programs
> the desired scopes of objects are not always cleanly nested but sometimes
> overlap in complex ways.
>
> Sometimes objects hold expensive resources and especially with programmin=
g
> patterns like threading or resumable functions the resources can remain
> blocked long after use if other functions in the same block require a lon=
g
> time to complete.
>
> This leads to programming patterns that try to mitigate this problem in
> 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:
>
> -
>
> The library needs to provide a function that releases expensive
> resources in addition to the destructor.
> -
>
> The library needs to keep track of the additional state in which
> resources are freed but the object not yet destroyed.
> -
>
> The user needs to locate such a function and understand its semantics
> to see if it really releases enough resources.
> -
>
> The neutered object still lingers in some form on the stack until the
> end of the scope.
> -
>
> The compiler can not diagnose at compile time when such an already
> neutered object is used accidentally due to code rewrite etc.
> -
>
> Diagnostics and other interactions that are tied to the destruction
> occur far removed in time from the time the object actually falls out =
of
> use.
>
>
> 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
> rather a list of variable or function parameter names.
>
> Variables in the enclosing scope cannot be deleted from within selection
> statements (if, switch), iteration statements (while, do, for), catch
> clauses or other conditionally executed code.
>
> When goto crosses delete local in the direction of the program flow then
> it deletes the object in the same way as when crossing =E2=80=9C}=E2=80=
=9D. When goto
> passes delete local it must also pass the point of declaration of the
> name.
>
> Optional: After delete local the name is free for reuse in a new variable
> declaration.
>
> --
>
> ---
> 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/.
>
--=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/.
--001a1132f53e7f28d7050572057c
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">If your classes depend on destructor ordering, then you ar=
e doing too much in destructors, and are better off putting the interesting=
part of the destructor into a member function and explicitly calling it.=
=C2=A0 In the destructor you can check if it has been called and then eithe=
r error or call it automatically.=C2=A0 The member function will have an ex=
pressive name that helps the reader understand what is going on, rather tha=
n hiding it in a nameless destructor.<div>=C2=A0 -Andrew.</div><div><br></d=
iv></div><div class=3D"gmail_extra"><br><div class=3D"gmail_quote">On Wed, =
Oct 15, 2014 at 9:14 AM, Michael Bruck <span dir=3D"ltr"><<a href=3D"mai=
lto:bruck.michael@gmail.com" target=3D"_blank">bruck.michael@gmail.com</a>&=
gt;</span> wrote:<br><blockquote class=3D"gmail_quote" style=3D"margin:0 0 =
0 .8ex;border-left:1px #ccc solid;padding-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">Hello everyone,</span><br></p><p dir=3D"lt=
r" style=3D"line-height:1.15;margin-top:0pt;margin-bottom:0pt"><br></p><p d=
ir=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:0=
pt">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 improv=
ements.</p><p dir=3D"ltr" style=3D"line-height:1.15;margin-top:0pt;margin-b=
ottom: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"><br></p><p dir=3D"ltr" style=3D"line-height:1.15=
;margin-top:0pt;margin-bottom:0pt">Regards,</p><p dir=3D"ltr" style=3D"line=
-height:1.15;margin-top:0pt;margin-bottom:0pt">Michael</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"><span sty=
le=3D"font-size:28px;font-family:'Trebuchet MS';color:rgb(0,0,0);wh=
ite-space:pre-wrap;background-color:transparent"><br></span></p><p dir=3D"l=
tr" 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-wra=
p;background-color:transparent"><font size=3D"4">Deleting local variables</=
font></span></p><h1 dir=3D"ltr" style=3D"line-height:1.15;margin-top:10pt;m=
argin-bottom:0pt"><span style=3D"font-family:'Trebuchet MS';color:r=
gb(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-height:1.15;margi=
n-top:0pt;margin-bottom:0pt"><span style=3D"font-size:15px;font-family:Aria=
l;color:rgb(0,0,0);white-space:pre-wrap;background-color:transparent">This =
proposal introduces a way to end the scope of a variable before its enclosi=
ng block ends.</span></p><br><p dir=3D"ltr" style=3D"line-height:1.15;margi=
n-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-color:tr=
ansparent">{</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;backgrou=
nd-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-in=
dent: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:tra=
nsparent">delete</span><span style=3D"font-size:15px;font-family:'Couri=
er New';color:rgb(0,0,0);white-space:pre-wrap;background-color:transpar=
ent"> </span><span style=3D"font-size:15px;font-family:'Courier New'=
;;color:rgb(0,0,0);font-weight:bold;white-space:pre-wrap;background-color:t=
ransparent">local</span><span style=3D"font-size:15px;font-family:'Cour=
ier New';color:rgb(0,0,0);white-space:pre-wrap;background-color:transpa=
rent"> foo, bar;</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;f=
ont-family:'Courier New';color:rgb(0,0,0);white-space:pre-wrap;back=
ground-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-space:pre-wrap;backgrou=
nd-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:'Tre=
buchet MS';color:rgb(0,0,0);white-space:pre-wrap;background-color:trans=
parent"><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;backgroun=
d-color:transparent">The =E2=80=9C} operator=E2=80=9D is powerful but but c=
omes with a pre-defined destruction order which is not suitable for all app=
lications. In real world programs the desired scopes of objects are not alw=
ays cleanly nested but sometimes overlap in complex ways.</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:Arial;color:rgb(0,0,0);white-space:pre-=
wrap;background-color:transparent">Sometimes objects hold expensive resourc=
es and especially with programming patterns like threading or resumable fun=
ctions the resources can remain blocked long after use if other functions i=
n the same block require a long time to complete.</span></p><br><p dir=3D"l=
tr" 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 leads to programming patterns that try t=
o 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;margi=
n-bottom:0pt"><span style=3D"font-size:15px;font-family:'Courier New=
9;;color:rgb(0,0,0);white-space:pre-wrap;background-color:transparent">{</s=
pan></p><p dir=3D"ltr" style=3D"line-height:1.15;margin-top:0pt;margin-bott=
om: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:transp=
arent">auto file =3D file_open_rlock("data_snippet");</span></p><=
p dir=3D"ltr" style=3D"line-height:1.15;margin-top:0pt;margin-bottom:0pt;te=
xt-indent:36pt"><span style=3D"font-size:15px;font-family:'Courier New&=
#39;;color:rgb(0,0,0);white-space:pre-wrap;background-color:transparent">au=
to 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"fon=
t-size:15px;font-family:'Courier New';color:rgb(0,0,0);white-space:=
pre-wrap;background-color:transparent">file.close();</span></p><br><p dir=
=3D"ltr" style=3D"line-height:1.15;margin-top:0pt;margin-bottom:0pt;text-in=
dent:36pt"><span style=3D"font-size:15px;font-family:'Courier New';=
color:rgb(0,0,0);white-space:pre-wrap;background-color:transparent">auto co=
nn =3D connect_to_peer("192.128.0.1");</span></p><p dir=3D"ltr" s=
tyle=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-color:transparent">conn.send(blob);<=
/span></p><p dir=3D"ltr" style=3D"line-height:1.15;margin-top:0pt;margin-bo=
ttom: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:tran=
sparent">blob.destroy();</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-siz=
e:15px;font-family:'Courier New';color:rgb(0,0,0);white-space:pre-w=
rap;background-color:transparent">auto reply =3D conn.fetch_reply();</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:transparen=
t">conn.disconnect();</span></p><br><p dir=3D"ltr" style=3D"line-height:1.1=
5;margin-top:0pt;margin-bottom:0pt;text-indent:36pt"><span style=3D"font-si=
ze:15px;font-family:'Courier New';color:rgb(0,0,0);white-space:pre-=
wrap;background-color:transparent">auto file2 =3D file_create("output&=
quot;);</span></p><p dir=3D"ltr" style=3D"line-height:1.15;margin-top:0pt;m=
argin-bottom:0pt;text-indent:36pt"><span style=3D"font-size:15px;font-famil=
y:'Courier New';color:rgb(0,0,0);white-space:pre-wrap;background-co=
lor:transparent">file2.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);white=
-space:pre-wrap;background-color:transparent">reply.destroy();</span></p><p=
dir=3D"ltr" style=3D"line-height:1.15;margin-top:0pt;margin-bottom:0pt;tex=
t-indent:36pt"><span style=3D"font-size:15px;font-family:'Courier New&#=
39;;color:rgb(0,0,0);white-space:pre-wrap;background-color:transparent">fil=
e2.close();</span></p><p dir=3D"ltr" style=3D"line-height:1.15;margin-top:0=
pt;margin-bottom:0pt"><span style=3D"font-size:15px;font-family:'Courie=
r New';color:rgb(0,0,0);white-space:pre-wrap;background-color:transpare=
nt">}</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:Arial;color:r=
gb(0,0,0);white-space:pre-wrap;background-color:transparent">There are a nu=
mber of problems with this solution:</span></p><ul style=3D"margin-top:0pt;=
margin-bottom:0pt"><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;backg=
round-color:transparent">The library needs to provide a function that relea=
ses expensive resources in addition to the destructor.</span></p></li><li d=
ir=3D"ltr" style=3D"list-style-type:disc;font-size:15px;font-family:Arial;c=
olor:rgb(0,0,0);vertical-align:baseline;background-color:transparent"><p di=
r=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 additional 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;margin-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 r=
eally releases enough resources.</span></p></li><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 neutered object s=
till lingers in some form on the stack until the end of the scope.</span></=
p></li><li dir=3D"ltr" style=3D"list-style-type:disc;font-size:15px;font-fa=
mily:Arial;color:rgb(0,0,0);vertical-align:baseline;background-color:transp=
arent"><p dir=3D"ltr" style=3D"line-height:1.15;margin-top:0pt;margin-botto=
m:0pt"><span style=3D"font-size:15px;white-space:pre-wrap;background-color:=
transparent">The compiler can not diagnose at compile time when such an alr=
eady neutered object is used accidentally due to code rewrite etc.</span></=
p></li><li dir=3D"ltr" style=3D"list-style-type:disc;font-size:15px;font-fa=
mily:Arial;color:rgb(0,0,0);vertical-align:baseline;background-color:transp=
arent"><p dir=3D"ltr" style=3D"line-height:1.15;margin-top:0pt;margin-botto=
m:0pt"><span style=3D"font-size:15px;white-space:pre-wrap;background-color:=
transparent">Diagnostics and other interactions that are tied to the destru=
ction 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;m=
argin-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">T=
his proposal would allow for the following code:</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-spac=
e: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"><sp=
an style=3D"font-size:15px;font-family:'Courier New';color:rgb(0,0,=
0);white-space:pre-wrap;background-color:transparent">auto file =3D file_op=
en_rlock("data_snippet");</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-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:=
9;Courier New';color:rgb(0,0,0);font-weight:bold;white-space:pre-wrap;b=
ackground-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:36=
pt"><span style=3D"font-size:15px;font-family:'Courier New';color:r=
gb(0,0,0);white-space:pre-wrap;background-color:transparent">auto conn =3D =
connect_to_peer("192.128.0.1");</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-color:transparent">conn.send(blob);</span><=
/p><p dir=3D"ltr" style=3D"line-height:1.15;margin-top:0pt;margin-bottom:0p=
t;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 local blob;</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);whit=
e-space:pre-wrap;background-color:transparent">auto reply =3D conn.fetch_re=
ply();</span></p><p dir=3D"ltr" style=3D"line-height:1.15;margin-top:0pt;ma=
rgin-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-wr=
ap;background-color:transparent">delete local conn;</span></p><br><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';col=
or:rgb(0,0,0);white-space:pre-wrap;background-color:transparent">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=
-space: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;t=
ext-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-col=
or:transparent">delete local file, reply;</span></p><p dir=3D"ltr" style=3D=
"line-height:1.15;margin-top:0pt;margin-bottom:0pt"><span style=3D"font-siz=
e:15px;font-family:'Courier New';color:rgb(0,0,0);white-space:pre-w=
rap;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-fam=
ily:'Trebuchet MS';color:rgb(0,0,0);white-space:pre-wrap;background=
-color:transparent"><font size=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:transparent">Unlike the regular </span><span style=3D=
"font-size:15px;font-family:'Courier New';color:rgb(0,0,0);white-sp=
ace:pre-wrap;background-color:transparent">delete</span><span style=3D"font=
-size:15px;font-family:Arial;color:rgb(0,0,0);white-space:pre-wrap;backgrou=
nd-color:transparent"> expression the argument is not a pointer but rather =
a list of variable or function parameter names.</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:Arial;color:rgb(0,0,0);white-space:pre-wrap;=
background-color:transparent">Variables in the enclosing scope cannot be de=
leted from within selection statements (</span><span style=3D"font-size:15p=
x;font-family:'Courier New';color:rgb(0,0,0);white-space:pre-wrap;b=
ackground-color:transparent">if</span><span style=3D"font-size:15px;font-fa=
mily:Arial;color:rgb(0,0,0);white-space:pre-wrap;background-color:transpare=
nt">, </span><span style=3D"font-size:15px;font-family:'Courier New'=
;;color:rgb(0,0,0);white-space:pre-wrap;background-color:transparent">switc=
h</span><span style=3D"font-size:15px;font-family:Arial;color:rgb(0,0,0);wh=
ite-space:pre-wrap;background-color:transparent">), iteration statements (<=
/span><span style=3D"font-size:15px;font-family:'Courier 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-spac=
e:pre-wrap;background-color:transparent">, </span><span style=3D"font-size:=
15px;font-family:'Courier New';color:rgb(0,0,0);white-space:pre-wra=
p;background-color:transparent">do</span><span style=3D"font-size:15px;font=
-family:Arial;color:rgb(0,0,0);white-space:pre-wrap;background-color:transp=
arent">, </span><span style=3D"font-size:15px;font-family:'Courier New&=
#39;;color:rgb(0,0,0);white-space:pre-wrap;background-color:transparent">fo=
r</span><span style=3D"font-size:15px;font-family:Arial;color:rgb(0,0,0);wh=
ite-space:pre-wrap;background-color:transparent">), </span><span style=3D"f=
ont-size:15px;font-family:'Courier New';color:rgb(0,0,0);white-spac=
e:pre-wrap;background-color:transparent">catch</span><span style=3D"font-si=
ze:15px;font-family:Arial;color:rgb(0,0,0);white-space:pre-wrap;background-=
color:transparent"> clauses or other conditionally executed code.</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:Arial;color:rgb(0,0,0);white=
-space:pre-wrap;background-color:transparent">When </span><span style=3D"fo=
nt-size:15px;font-family:'Courier New';color:rgb(0,0,0);white-space=
:pre-wrap;background-color:transparent">goto</span><span style=3D"font-size=
:15px;font-family:Arial;color:rgb(0,0,0);white-space:pre-wrap;background-co=
lor:transparent"> crosses </span><span style=3D"font-size:15px;font-family:=
'Courier New';color:rgb(0,0,0);white-space:pre-wrap;background-colo=
r: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">=
in the direction of the program flow then it deletes the object in the sam=
e way as when crossing =E2=80=9C}=E2=80=9D. When </span><span style=3D"font=
-size:15px;font-family:'Courier New';color:rgb(0,0,0);white-space:p=
re-wrap;background-color:transparent">goto</span><span style=3D"font-size:1=
5px;font-family:Arial;color:rgb(0,0,0);white-space:pre-wrap;background-colo=
r:transparent"> passes </span><span style=3D"font-size:15px;font-family:=
9;Courier New';color:rgb(0,0,0);white-space:pre-wrap;background-color:t=
ransparent">delete local</span><span style=3D"font-size:15px;font-family:Ar=
ial;color:rgb(0,0,0);white-space:pre-wrap;background-color:transparent"> it=
must also pass the point of declaration of the name.</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:Arial;color:rgb(0,0,0);white-space:pre-=
wrap;background-color:transparent">Optional: After </span><span style=3D"fo=
nt-size:15px;font-family:'Courier New';color:rgb(0,0,0);white-space=
:pre-wrap;background-color:transparent">delete local</span><span style=3D"f=
ont-size:15px;font-family:Arial;color:rgb(0,0,0);white-space:pre-wrap;backg=
round-color:transparent"> the name is free for reuse in a new variable decl=
aration.</span></p><span class=3D"HOEnZb"><font color=3D"#888888"><h1 dir=
=3D"ltr" style=3D"line-height:1.15;margin-top:10pt;margin-bottom:0pt"><br><=
/h1></font></span></span></div><span class=3D"HOEnZb"><font color=3D"#88888=
8">
<p></p>
-- <br>
<br>
--- <br>
You received this message because you are subscribed to the Google Groups &=
quot;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"mailto:std-proposals+unsubscribe@isocpp.org" target=3D"_=
blank">std-proposals+unsubscribe@isocpp.org</a>.<br>
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org" target=3D"_blank">std-proposals@isocpp.org</a>.<br>
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/" target=3D"_blank">http://groups.google.com/a/isocpp.org/gro=
up/std-proposals/</a>.<br>
</font></span></blockquote></div><br></div>
<p></p>
-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;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"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 />
--001a1132f53e7f28d7050572057c--
.
Author: Michael Bruck <bruck.michael@gmail.com>
Date: Wed, 15 Oct 2014 02:06:54 -0700 (PDT)
Raw View
------=_Part_98_112874653.1413364014167
Content-Type: text/plain; charset=UTF-8
Good point about restricting visibility. One caveat though, the destruction
of s would always be done by the caller upon return unless the function is
inlined. I'll add a clarification for later versions.
Michael
On Wednesday, October 15, 2014 10:33:26 AM UTC+2, Roman Perepelitsa wrote:
>
> 2014-10-15 9:33 GMT+02:00 Markus Grech <markus...@gmail.com <javascript:>>
> :
>
>> Why not just limit the scope by adding an additional pair of {}? Is there
>> any advantage to using "delete local"?
>>
>
> The "delete local" construct, unlike an extra pair of {}, works with
> function parameters.
>
> void foo(std::string s)
> {
> bar(std::move(s));
> // Make sure we don't use 's' after it's been moved.
> // Free resources if it still has any.
> delete local s;
> ...
> }
>
> Roman Perepelitsa.
>
--
---
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/.
------=_Part_98_112874653.1413364014167
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">Good point about restricting visibility. One caveat though=
, the destruction of s would always be done by the caller upon return unles=
s the function is inlined. I'll add a clarification for later versions.<div=
><br></div><div>Michael<br><div><br></div><div><br>On Wednesday, October 15=
, 2014 10:33:26 AM UTC+2, Roman Perepelitsa wrote:<blockquote class=3D"gmai=
l_quote" style=3D"margin: 0;margin-left: 0.8ex;border-left: 1px #ccc solid;=
padding-left: 1ex;"><div dir=3D"ltr"><div><div class=3D"gmail_quote">2014-1=
0-15 9:33 GMT+02:00 Markus Grech <span dir=3D"ltr"><<a href=3D"javascrip=
t:" target=3D"_blank" gdf-obfuscated-mailto=3D"ervP1MZB6aEJ" onmousedown=3D=
"this.href=3D'javascript:';return true;" onclick=3D"this.href=3D'javascript=
:';return true;">markus...@gmail.com</a>></span>:<br><blockquote class=
=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;border-left-width:1px;bo=
rder-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">=
<div dir=3D"ltr">Why not just limit the scope by adding an additional pair =
of {}? Is there any advantage to using "delete local"?</div></blockquote><d=
iv><br></div><div>The "delete local" construct, unlike an extra pair of {},=
works with function parameters.</div><div><br></div><div><font face=3D"cou=
rier new, monospace"> void foo(std::string s)</font></div><div><font =
face=3D"courier new, monospace"> {</font></div><div><font face=3D"cou=
rier new, monospace"> bar(std::move(s));</font></div><div><fon=
t face=3D"courier new, monospace"> // Make sure we don't use '=
s' after it's been moved.</font></div><div><font face=3D"courier new, monos=
pace"> // Free resources if it still has any.</font></div><div=
><font face=3D"courier new, monospace"> delete local s;</font>=
</div><div><font face=3D"courier new, monospace"> ...</font></=
div><div><font face=3D"courier new, monospace"> }</font></div><div><b=
r></div><div>Roman Perepelitsa.</div></div></div></div>
</blockquote></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" 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_98_112874653.1413364014167--
.
Author: Ville Voutilainen <ville.voutilainen@gmail.com>
Date: Wed, 15 Oct 2014 12:14:30 +0300
Raw View
On 15 October 2014 12:06, Michael Bruck <bruck.michael@gmail.com> wrote:
> Good point about restricting visibility. One caveat though, the destruction
> of s would always be done by the caller upon return unless the function is
> inlined. I'll add a clarification for later versions.
This proposal is going to be facing an uphill battle if it uses the
keyword 'delete'.
--
---
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/.
.
Author: Michael Bruck <bruck.michael@gmail.com>
Date: Wed, 15 Oct 2014 02:18:59 -0700 (PDT)
Raw View
------=_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. In the destructor you can check if it has been called =
and then either error or call it automatically. 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> -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"><<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>></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" 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--
.
Author: Michael Bruck <bruck.michael@gmail.com>
Date: Wed, 15 Oct 2014 02:27:20 -0700 (PDT)
Raw View
------=_Part_2510_326733686.1413365240128
Content-Type: text/plain; charset=UTF-8
I am open for suggestions. I only picked something so I could put the
concept into writing.
Michael
On Wednesday, October 15, 2014 11:14:31 AM UTC+2, Ville Voutilainen wrote:
>
> On 15 October 2014 12:06, Michael Bruck <bruck....@gmail.com <javascript:>>
> wrote:
> > Good point about restricting visibility. One caveat though, the
> destruction
> > of s would always be done by the caller upon return unless the function
> is
> > inlined. I'll add a clarification for later versions.
>
>
> This proposal is going to be facing an uphill battle if it uses the
> keyword 'delete'.
>
--
---
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/.
------=_Part_2510_326733686.1413365240128
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr"><div>I am open for suggestions. I only picked something so=
I could put the concept into writing.<br></div><div><br></div><div>Michael=
</div><br><br>On Wednesday, October 15, 2014 11:14:31 AM UTC+2, Ville Vouti=
lainen wrote:<blockquote class=3D"gmail_quote" style=3D"margin: 0;margin-le=
ft: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;">On 15 October 201=
4 12:06, Michael Bruck <<a href=3D"javascript:" target=3D"_blank" gdf-ob=
fuscated-mailto=3D"QeCD9tzagiAJ" onmousedown=3D"this.href=3D'javascript:';r=
eturn true;" onclick=3D"this.href=3D'javascript:';return true;">bruck....@g=
mail.com</a>> wrote:
<br>> Good point about restricting visibility. One caveat though, the de=
struction
<br>> of s would always be done by the caller upon return unless the fun=
ction is
<br>> inlined. I'll add a clarification for later versions.
<br>
<br>
<br>This proposal is going to be facing an uphill battle if it uses the
<br>keyword 'delete'.
<br></blockquote></div>
<p></p>
-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;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"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_2510_326733686.1413365240128--
.
Author: Andrew Tomazos <andrewtomazos@gmail.com>
Date: Wed, 15 Oct 2014 12:06:49 +0200
Raw View
--001a11c340ee5037230505734af2
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
Sorry, I should have actually read your proposal - specifically I think:
{
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();
}
is more readable than:
{
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;
}
On Wed, Oct 15, 2014 at 11:18 AM, Michael Bruck <bruck.michael@gmail.com>
wrote:
> I think the proposal addresses a number of drawbacks with that approach. =
I
> think that having a unified method to dispose of these objects without
> needing special support in your library has clear advantages.
>
> 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
>> much in destructors, and are better off putting the interesting part of =
the
>> destructor into a member function and explicitly calling it. In the
>> destructor you can check if it has been called and then either error or
>> call it automatically. The member function will have an expressive name
>> that helps the reader understand what is going on, rather than hiding it=
in
>> a nameless destructor.
>> -Andrew.
>>
>>
>> On Wed, Oct 15, 2014 at 9:14 AM, Michael Bruck <bruck....@gmail.com>
>> wrote:
>>
>>> Hello everyone,
>>>
>>>
>>>
>>> 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.
>>>
>>>
>>>
>>>
>>> Regards,
>>>
>>> Michael
>>>
>>>
>>>
>>> Deleting local variables
>>> Summary
>>>
>>> This proposal introduces a way to end the scope of a variable before it=
s
>>> 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-d=
efined
>>> destruction order which is not suitable for all applications. In real w=
orld
>>> programs the desired scopes of objects are not always cleanly nested bu=
t
>>> sometimes overlap in complex ways.
>>>
>>> Sometimes objects hold expensive resources and especially with
>>> programming patterns like threading or resumable functions the resource=
s
>>> can remain blocked long after use if other functions in the same block
>>> require a long time to complete.
>>>
>>> This leads to programming patterns that try to mitigate this problem in
>>> 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:
>>>
>>> -
>>>
>>> The library needs to provide a function that releases expensive
>>> resources in addition to the destructor.
>>> -
>>>
>>> The library needs to keep track of the additional state in which
>>> resources are freed but the object not yet destroyed.
>>> -
>>>
>>> The user needs to locate such a function and understand its
>>> semantics to see if it really releases enough resources.
>>> -
>>>
>>> The neutered object still lingers in some form on the stack until
>>> the end of the scope.
>>> -
>>>
>>> The compiler can not diagnose at compile time when such an already
>>> neutered object is used accidentally due to code rewrite etc.
>>> -
>>>
>>> Diagnostics and other interactions that are tied to the destruction
>>> occur far removed in time from the time the object actually falls ou=
t of
>>> use.
>>>
>>>
>>> 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
>>> rather a list of variable or function parameter names.
>>>
>>> Variables in the enclosing scope cannot be deleted from within selectio=
n
>>> statements (if, switch), iteration statements (while, do, for), catch
>>> clauses or other conditionally executed code.
>>>
>>> When goto crosses delete local in the direction of the program flow
>>> then it deletes the object in the same way as when crossing =E2=80=9C}=
=E2=80=9D. When
>>> goto passes delete local it must also pass the point of declaration of
>>> the name.
>>>
>>> Optional: After delete local the name is free for reuse in a new
>>> variable declaration.
>>>
>>> --
>>>
>>> ---
>>> 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-proposal...@isocpp.org.
>>> To post to this group, send email to std-pr...@isocpp.org.
>>> Visit this group at http://groups.google.com/a/isocpp.org/group/std-
>>> proposals/.
>>>
>>
>> --
>
> ---
> 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/.
>
--=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/.
--001a11c340ee5037230505734af2
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">Sorry, I should have actually read your proposal - specifi=
cally I think:<div><br></div><div><p dir=3D"ltr" style=3D"font-family:arial=
,sans-serif;font-size:13px;line-height:1.15;margin-top:0pt;margin-bottom:0p=
t"><span style=3D"font-size:15px;font-family:'Courier New';color:rg=
b(0,0,0);white-space:pre-wrap;background-color:transparent">{</span></p><p =
dir=3D"ltr" style=3D"font-family:arial,sans-serif;font-size:13px;line-heigh=
t:1.15;margin-top:0pt;margin-bottom:0pt;text-indent:36pt"><span style=3D"fo=
nt-size:15px;font-family:'Courier New';color:rgb(0,0,0);white-space=
:pre-wrap;background-color:transparent">auto file =3D file_open_rlock("=
;data_snippet");</span></p><p dir=3D"ltr" style=3D"font-family:arial,s=
ans-serif;font-size:13px;line-height:1.15;margin-top:0pt;margin-bottom:0pt;=
text-indent:36pt"><span style=3D"font-size:15px;font-family:'Courier Ne=
w';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"font-fami=
ly:arial,sans-serif;font-size:13px;line-height:1.15;margin-top:0pt;margin-b=
ottom: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:tra=
nsparent">file.close();</span></p><br style=3D"font-family:arial,sans-serif=
;font-size:13px"><p dir=3D"ltr" style=3D"font-family:arial,sans-serif;font-=
size:13px;line-height:1.15;margin-top:0pt;margin-bottom:0pt;text-indent:36p=
t"><span style=3D"font-size:15px;font-family:'Courier New';color:rg=
b(0,0,0);white-space:pre-wrap;background-color:transparent">auto conn =3D c=
onnect_to_peer("192.128.0.1");</span></p><p dir=3D"ltr" style=3D"=
font-family:arial,sans-serif;font-size:13px;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:transparent">conn.send(blob);</span></p><p dir=3D"ltr" style=3D"font-=
family:arial,sans-serif;font-size:13px;line-height:1.15;margin-top:0pt;marg=
in-bottom:0pt;text-indent:36pt"><span style=3D"font-size:15px;font-family:&=
#39;Courier New';color:rgb(0,0,0);white-space:pre-wrap;background-color=
:transparent">blob.destroy();</span></p><p dir=3D"ltr" style=3D"font-family=
:arial,sans-serif;font-size:13px;line-height:1.15;margin-top:0pt;margin-bot=
tom: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:trans=
parent">auto reply =3D conn.fetch_reply();</span></p><p dir=3D"ltr" style=
=3D"font-family:arial,sans-serif;font-size:13px;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;backgro=
und-color:transparent">conn.disconnect();</span></p><br style=3D"font-famil=
y:arial,sans-serif;font-size:13px"><p dir=3D"ltr" style=3D"font-family:aria=
l,sans-serif;font-size:13px;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:transparen=
t">auto file2 =3D file_create("output");</span></p><p dir=3D"ltr"=
style=3D"font-family:arial,sans-serif;font-size:13px;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;b=
ackground-color:transparent">file2.write(reply);</span></p><p dir=3D"ltr" s=
tyle=3D"font-family:arial,sans-serif;font-size:13px;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;bac=
kground-color:transparent">reply.destroy();</span></p><p dir=3D"ltr" style=
=3D"font-family:arial,sans-serif;font-size:13px;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;backgro=
und-color:transparent">file2.close();</span></p><p dir=3D"ltr" style=3D"fon=
t-family:arial,sans-serif;font-size:13px;line-height:1.15;margin-top:0pt;ma=
rgin-bottom:0pt"><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"font-family:arial,sans-serif;font-size:1=
3px;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-space:pr=
e-wrap;background-color:transparent"><br></span></p><p style=3D"font-family=
:arial,sans-serif;font-size:13px;line-height:1.15;margin-top:0pt;margin-bot=
tom:0pt"><span style=3D"font-size:15px;font-family:'Courier New';co=
lor:rgb(0,0,0);white-space:pre-wrap;background-color:transparent">is more r=
eadable than:</span></p><p style=3D"font-family:arial,sans-serif;font-size:=
13px;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-space:p=
re-wrap;background-color:transparent"><br></span></p><p dir=3D"ltr" style=
=3D"font-family:arial,sans-serif;font-size:13px;line-height:1.15;margin-top=
:0pt;margin-bottom:0pt"><span style=3D"color:rgb(0,0,0);font-family:'Co=
urier New';font-size:15px;white-space:pre-wrap;line-height:1.15;backgro=
und-color:transparent">{</span><br></p><p dir=3D"ltr" style=3D"font-family:=
arial,sans-serif;font-size:13px;line-height:1.15;margin-top:0pt;margin-bott=
om: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:transp=
arent">auto file =3D file_open_rlock("data_snippet");</span></p><=
p dir=3D"ltr" style=3D"font-family:arial,sans-serif;font-size:13px;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-spa=
ce:pre-wrap;background-color:transparent">auto blob =3D file.fetch_all();</=
span></p><p dir=3D"ltr" style=3D"font-family:arial,sans-serif;font-size:13p=
x;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=
local file;</span></p><p style=3D"font-family:arial,sans-serif;font-size:1=
3px;line-height:1.15;margin-top:0pt;margin-bottom:0pt"><br style=3D"line-he=
ight:normal"></p><p dir=3D"ltr" style=3D"font-family:arial,sans-serif;font-=
size:13px;line-height:1.15;margin-top:0pt;margin-bottom:0pt;text-indent:36p=
t"><span style=3D"font-size:15px;font-family:'Courier New';color:rg=
b(0,0,0);white-space:pre-wrap;background-color:transparent">auto conn =3D c=
onnect_to_peer("192.128.0.1");</span></p><p dir=3D"ltr" style=3D"=
font-family:arial,sans-serif;font-size:13px;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:transparent">conn.send(blob);</span></p><p dir=3D"ltr" style=3D"font-=
family:arial,sans-serif;font-size:13px;line-height:1.15;margin-top:0pt;marg=
in-bottom:0pt;text-indent:36pt"><span style=3D"font-size:15px;font-family:&=
#39;Courier New';color:rgb(0,0,0);font-weight:bold;white-space:pre-wrap=
;background-color:transparent">delete local blob;</span></p><p dir=3D"ltr" =
style=3D"font-family:arial,sans-serif;font-size:13px;line-height:1.15;margi=
n-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;ba=
ckground-color:transparent">auto reply =3D conn.fetch_reply();</span></p><p=
dir=3D"ltr" style=3D"font-family:arial,sans-serif;font-size:13px;line-heig=
ht:1.15;margin-top:0pt;margin-bottom:0pt;text-indent:36pt"><span style=3D"f=
ont-size:15px;font-family:'Courier New';color:rgb(0,0,0);font-weigh=
t:bold;white-space:pre-wrap;background-color:transparent">delete local conn=
;</span></p><p style=3D"font-family:arial,sans-serif;font-size:13px;line-he=
ight:1.15;margin-top:0pt;margin-bottom:0pt"><br style=3D"line-height:normal=
"></p><p dir=3D"ltr" style=3D"font-family:arial,sans-serif;font-size:13px;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);wh=
ite-space:pre-wrap;background-color:transparent">auto file =3D file_create(=
"output");</span></p><p dir=3D"ltr" style=3D"font-family:arial,sa=
ns-serif;font-size:13px;line-height:1.15;margin-top:0pt;margin-bottom:0pt;t=
ext-indent:36pt"><span style=3D"font-size:15px;font-family:'Courier New=
';color:rgb(0,0,0);white-space:pre-wrap;background-color:transparent">f=
ile.write(reply);</span></p><p dir=3D"ltr" style=3D"font-family:arial,sans-=
serif;font-size:13px;line-height:1.15;margin-top:0pt;margin-bottom:0pt;text=
-indent:36pt"><span style=3D"font-size:15px;font-family:'Courier New=
9;;color:rgb(0,0,0);font-weight:bold;white-space:pre-wrap;background-color:=
transparent">delete local file, reply;</span></p><p dir=3D"ltr" style=3D"fo=
nt-family:arial,sans-serif;font-size:13px;line-height:1.15;margin-top:0pt;m=
argin-bottom:0pt"><span style=3D"font-size:15px;font-family:'Courier Ne=
w';color:rgb(0,0,0);white-space:pre-wrap;background-color:transparent">=
}</span></p><p dir=3D"ltr" style=3D"font-family:arial,sans-serif;font-size:=
13px;line-height:1.15;margin-top:0pt;margin-bottom:0pt"><br></p><p style=3D=
"font-family:arial,sans-serif;font-size:13px;line-height:1.15;margin-top:0p=
t;margin-bottom:0pt"><br></p><p style=3D"font-family:arial,sans-serif;font-=
size:13px;line-height:1.15;margin-top:0pt;margin-bottom:0pt"><br></p><div c=
lass=3D"gmail_extra"><div class=3D"gmail_quote">On Wed, Oct 15, 2014 at 11:=
18 AM, Michael Bruck <span dir=3D"ltr"><<a href=3D"mailto:bruck.michael@=
gmail.com" target=3D"_blank">bruck.michael@gmail.com</a>></span> wrote:<=
br><blockquote class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;bord=
er-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:soli=
d;padding-left:1ex"><div dir=3D"ltr">I think the proposal addresses a numbe=
r of drawbacks with that approach. I think that having a unified method to =
dispose of these objects without needing special support in your library ha=
s clear advantages.=C2=A0<div><br></div><div><div><div>Michael<span class=
=3D""><br><br>On Wednesday, October 15, 2014 10:36:03 AM UTC+2, Andrew Toma=
zos wrote:</span><blockquote class=3D"gmail_quote" style=3D"margin:0px 0px =
0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-l=
eft-style:solid;padding-left:1ex"><span class=3D""><div dir=3D"ltr">If your=
classes depend on destructor ordering, then you are doing too much in dest=
ructors, and are better off putting the interesting part of the destructor =
into a member function and explicitly calling it.=C2=A0 In the destructor y=
ou can check if it has been called and then either error or call it automat=
ically.=C2=A0 The member function will have an expressive name that helps t=
he reader understand what is going on, rather than hiding it in a nameless =
destructor.<div>=C2=A0 -Andrew.</div><div><br></div></div></span><div><br><=
div class=3D"gmail_quote"><div><div class=3D"h5">On Wed, Oct 15, 2014 at 9:=
14 AM, Michael Bruck <span dir=3D"ltr"><<a>bruck....@gmail.com</a>></=
span> wrote:<br></div></div><blockquote class=3D"gmail_quote" style=3D"marg=
in:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,20=
4);border-left-style:solid;padding-left:1ex"><div><div class=3D"h5"><div di=
r=3D"ltr"><span><p dir=3D"ltr" style=3D"line-height:1.15;margin-top:0pt;mar=
gin-bottom:0pt"><span style=3D"line-height:1.15">Hello everyone,</span><br>=
</p><p dir=3D"ltr" style=3D"line-height:1.15;margin-top:0pt;margin-bottom:0=
pt"><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">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"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"><br></p><p dir=3D"ltr" style=3D"=
line-height:1.15;margin-top:0pt;margin-bottom:0pt">Regards,</p><p dir=3D"lt=
r" style=3D"line-height:1.15;margin-top:0pt;margin-bottom:0pt">Michael</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-botto=
m:0pt"><span style=3D"font-size:28px;font-family:'Trebuchet MS';col=
or:rgb(0,0,0);white-space:pre-wrap;background-color:transparent"><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);whi=
te-space:pre-wrap;background-color:transparent"><font size=3D"4">Deleting l=
ocal variables</font></span></p><h1 dir=3D"ltr" style=3D"line-height:1.15;m=
argin-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 size=3D"4">Summary</font></span></h1><p dir=3D"ltr" style=3D"line-h=
eight: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:tr=
ansparent">This proposal introduces a way to end the scope of a variable be=
fore its enclosing block ends.</span></p><br><p dir=3D"ltr" style=3D"line-h=
eight: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;bac=
kground-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);white-space:p=
re-wrap;background-color:transparent">std::string foo, bar;</span></p><p di=
r=3D"ltr" style=3D"line-height:1.15;margin-top:0pt;margin-bottom:0pt;text-i=
ndent:36pt"><span style=3D"font-size:15px;font-family:'Courier New'=
;color:rgb(0,0,0);white-space:pre-wrap;background-color:transparent">...</s=
pan></p><p dir=3D"ltr" style=3D"line-height:1.15;margin-top:0pt;margin-bott=
om:0pt;text-indent:36pt"><span style=3D"font-size:15px;font-family:'Cou=
rier New';color:rgb(0,0,0);font-weight:bold;white-space:pre-wrap;backgr=
ound-color:transparent">delete</span><span style=3D"font-size:15px;font-fam=
ily:'Courier New';color:rgb(0,0,0);white-space:pre-wrap;background-=
color:transparent"> </span><span style=3D"font-size:15px;font-family:'C=
ourier New';color:rgb(0,0,0);font-weight:bold;white-space:pre-wrap;back=
ground-color:transparent">local</span><span style=3D"font-size:15px;font-fa=
mily:'Courier New';color:rgb(0,0,0);white-space:pre-wrap;background=
-color:transparent"> foo, bar;</span></p><p dir=3D"ltr" style=3D"line-heigh=
t:1.15;margin-top:0pt;margin-bottom:0pt;text-indent:36pt"><span style=3D"fo=
nt-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-space:pr=
e-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;backgr=
ound-color:transparent"><font size=3D"4">Motivation</font></span></h1><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">The =E2=80=9C} operator=E2=80=9D is pow=
erful but but comes with a pre-defined destruction order which is not suita=
ble for all applications. In real world programs the desired scopes of obje=
cts are not always cleanly nested but sometimes overlap in complex ways.</s=
pan></p><p dir=3D"ltr" style=3D"line-height:1.15;margin-top:0pt;margin-bott=
om:0pt"><span style=3D"font-size:15px;font-family:Arial;color:rgb(0,0,0);wh=
ite-space:pre-wrap;background-color:transparent">Sometimes objects hold exp=
ensive resources and especially with programming patterns like threading or=
resumable functions the resources can remain blocked long after use if oth=
er functions in the same block require a long time to complete.</span></p><=
br><p dir=3D"ltr" style=3D"line-height:1.15;margin-top:0pt;margin-bottom:0p=
t"><span style=3D"font-size:15px;font-family:Arial;color:rgb(0,0,0);white-s=
pace:pre-wrap;background-color:transparent">This leads to programming patte=
rns that try to mitigate this problem in suboptimal ways. A typical approac=
h 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:'=
Courier New';color:rgb(0,0,0);white-space:pre-wrap;background-color:tra=
nsparent">{</span></p><p dir=3D"ltr" style=3D"line-height:1.15;margin-top:0=
pt;margin-bottom:0pt;text-indent:36pt"><span style=3D"font-size:15px;font-f=
amily:'Courier New';color:rgb(0,0,0);white-space:pre-wrap;backgroun=
d-color:transparent">auto file =3D file_open_rlock("data_snippet"=
<u></u>);</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: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:36p=
t"><span style=3D"font-size:15px;font-family:'Courier New';color:rg=
b(0,0,0);white-space:pre-wrap;background-color:transparent">file.close();</=
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"font-size:15px;font-family:=
9;Courier New';color:rgb(0,0,0);white-space:pre-wrap;background-color:t=
ransparent">auto conn =3D connect_to_peer("192.128.0.1")<u></u>;<=
/span></p><p dir=3D"ltr" style=3D"line-height:1.15;margin-top:0pt;margin-bo=
ttom: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:tran=
sparent">conn.send(blob);</span></p><p dir=3D"ltr" style=3D"line-height:1.1=
5;margin-top:0pt;margin-bottom:0pt;text-indent:36pt"><span style=3D"font-si=
ze:15px;font-family:'Courier New';color:rgb(0,0,0);white-space:pre-=
wrap;background-color:transparent">blob.destroy();</span></p><p dir=3D"ltr"=
style=3D"line-height:1.15;margin-top:0pt;margin-bottom:0pt;text-indent:36p=
t"><span style=3D"font-size:15px;font-family:'Courier New';color:rg=
b(0,0,0);white-space:pre-wrap;background-color:transparent">auto reply =3D =
conn.fetch_reply();</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;b=
ackground-color:transparent">conn.disconnect();</span></p><br><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:r=
gb(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-he=
ight: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">file2.write(reply);</span></p><p=
dir=3D"ltr" style=3D"line-height:1.15;margin-top:0pt;margin-bottom:0pt;tex=
t-indent:36pt"><span style=3D"font-size:15px;font-family:'Courier New&#=
39;;color:rgb(0,0,0);white-space:pre-wrap;background-color:transparent">rep=
ly.destroy();</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;backgro=
und-color:transparent">file2.close();</span></p><p dir=3D"ltr" style=3D"lin=
e-height:1.15;margin-top:0pt;margin-bottom:0pt"><span style=3D"font-size:15=
px;font-family:'Courier New';color:rgb(0,0,0);white-space:pre-wrap;=
background-color:transparent">}</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:Arial;color:rgb(0,0,0);white-space:pre-wrap;background-color:t=
ransparent">There are a number of problems with this solution:</span></p><u=
l style=3D"margin-top:0pt;margin-bottom:0pt"><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-h=
eight: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 pro=
vide a function that releases expensive resources in addition to the destru=
ctor.</span></p></li><li dir=3D"ltr" style=3D"list-style-type:disc;font-siz=
e:15px;font-family:Arial;color:rgb(0,0,0);vertical-align:baseline;backgroun=
d-color:transparent"><p dir=3D"ltr" style=3D"line-height:1.15;margin-top:0p=
t;margin-bottom:0pt"><span style=3D"font-size:15px;white-space:pre-wrap;bac=
kground-color:transparent">The library needs to keep track of the additiona=
l state in which resources are freed but the object not yet destroyed.</spa=
n></p></li><li dir=3D"ltr" style=3D"list-style-type:disc;font-size:15px;fon=
t-family:Arial;color:rgb(0,0,0);vertical-align:baseline;background-color:tr=
ansparent"><p dir=3D"ltr" style=3D"line-height:1.15;margin-top:0pt;margin-b=
ottom:0pt"><span style=3D"font-size:15px;white-space:pre-wrap;background-co=
lor:transparent">The user needs to locate such a function and understand it=
s semantics to see if it really releases enough resources.</span></p></li><=
li dir=3D"ltr" style=3D"list-style-type:disc;font-size:15px;font-family:Ari=
al;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:transpar=
ent">The neutered object still lingers in some form on the stack until the =
end of the scope.</span></p></li><li dir=3D"ltr" style=3D"list-style-type:d=
isc;font-size:15px;font-family:Arial;color:rgb(0,0,0);vertical-align:baseli=
ne;background-color:transparent"><p dir=3D"ltr" style=3D"line-height:1.15;m=
argin-top:0pt;margin-bottom:0pt"><span style=3D"font-size:15px;white-space:=
pre-wrap;background-color:transparent">The compiler can not diagnose at com=
pile 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-type:d=
isc;font-size:15px;font-family:Arial;color:rgb(0,0,0);vertical-align:baseli=
ne;background-color:transparent"><p dir=3D"ltr" style=3D"line-height:1.15;m=
argin-top:0pt;margin-bottom:0pt"><span style=3D"font-size:15px;white-space:=
pre-wrap;background-color:transparent">Diagnostics and other interactions t=
hat 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" s=
tyle=3D"line-height:1.15;margin-top:0pt;margin-bottom:0pt"><span style=3D"f=
ont-size:15px;font-family:Arial;color:rgb(0,0,0);white-space:pre-wrap;backg=
round-color:transparent">This proposal would allow for the following code:<=
/span></p><p dir=3D"ltr" style=3D"line-height:1.15;margin-top:0pt;margin-bo=
ttom:0pt"><span style=3D"font-size:15px;font-family:'Courier New';c=
olor: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: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:transparen=
t">auto file =3D file_open_rlock("data_snippet"<u></u>);</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 N=
ew';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-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);font-weig=
ht:bold;white-space:pre-wrap;background-color:transparent">delete local fil=
e;</span></p><br><p dir=3D"ltr" style=3D"line-height:1.15;margin-top:0pt;ma=
rgin-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-col=
or:transparent">auto conn =3D connect_to_peer("192.128.0.1")<u></=
u>;</span></p><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:&#=
39;Courier New';color:rgb(0,0,0);white-space:pre-wrap;background-color:=
transparent">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"fon=
t-size:15px;font-family:'Courier New';color:rgb(0,0,0);font-weight:=
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-bo=
ttom: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:tran=
sparent">auto reply =3D conn.fetch_reply();</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);font-weight:bold;white-space:pre-wrap;background-color:transparent">dele=
te local conn;</span></p><br><p dir=3D"ltr" style=3D"line-height:1.15;margi=
n-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;ba=
ckground-color:transparent">auto file =3D file_create("output");<=
/span></p><p dir=3D"ltr" style=3D"line-height:1.15;margin-top:0pt;margin-bo=
ttom: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:tran=
sparent">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:bo=
ld;white-space:pre-wrap;background-color:transparent">delete local file, re=
ply;</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&#=
39;;color:rgb(0,0,0);white-space:pre-wrap;background-color:transparent">}</=
span></p><br><h1 dir=3D"ltr" style=3D"line-height:1.15;margin-top:10pt;marg=
in-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">=
Details</font></span></h1><br><p dir=3D"ltr" style=3D"line-height:1.15;marg=
in-top:0pt;margin-bottom:0pt"><span style=3D"font-size:15px;font-family:Ari=
al;color:rgb(0,0,0);white-space:pre-wrap;background-color:transparent">Unli=
ke the regular </span><span style=3D"font-size:15px;font-family:'Courie=
r New';color:rgb(0,0,0);white-space:pre-wrap;background-color:transpare=
nt">delete</span><span style=3D"font-size:15px;font-family:Arial;color:rgb(=
0,0,0);white-space:pre-wrap;background-color:transparent"> expression the a=
rgument is not a pointer but rather a list of variable or function paramete=
r names.</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:Arial;colo=
r:rgb(0,0,0);white-space:pre-wrap;background-color:transparent">Variables i=
n 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><sp=
an style=3D"font-size:15px;font-family:Arial;color:rgb(0,0,0);white-space:p=
re-wrap;background-color:transparent">, </span><span style=3D"font-size:15p=
x;font-family:'Courier New';color:rgb(0,0,0);white-space:pre-wrap;b=
ackground-color:transparent">switch</span><span style=3D"font-size:15px;fon=
t-family:Arial;color:rgb(0,0,0);white-space:pre-wrap;background-color:trans=
parent">), iteration statements (</span><span style=3D"font-size:15px;font-=
family:'Courier New';color:rgb(0,0,0);white-space:pre-wrap;backgrou=
nd-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';co=
lor:rgb(0,0,0);white-space:pre-wrap;background-color:transparent">do</span>=
<span style=3D"font-size:15px;font-family:Arial;color:rgb(0,0,0);white-spac=
e:pre-wrap;background-color:transparent">, </span><span style=3D"font-size:=
15px;font-family:'Courier New';color:rgb(0,0,0);white-space:pre-wra=
p;background-color:transparent">for</span><span style=3D"font-size:15px;fon=
t-family:Arial;color:rgb(0,0,0);white-space:pre-wrap;background-color:trans=
parent">), </span><span style=3D"font-size:15px;font-family:'Courier Ne=
w';color:rgb(0,0,0);white-space:pre-wrap;background-color:transparent">=
catch</span><span style=3D"font-size:15px;font-family:Arial;color:rgb(0,0,0=
);white-space:pre-wrap;background-color:transparent"> clauses or other cond=
itionally executed code.</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-f=
amily:Arial;color:rgb(0,0,0);white-space:pre-wrap;background-color:transpar=
ent">When </span><span style=3D"font-size:15px;font-family:'Courier New=
';color:rgb(0,0,0);white-space:pre-wrap;background-color:transparent">g=
oto</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 st=
yle=3D"font-size:15px;font-family:'Courier New';color:rgb(0,0,0);wh=
ite-space:pre-wrap;background-color:transparent">delete local</span><span s=
tyle=3D"font-size:15px;font-family:Arial;color:rgb(0,0,0);white-space:pre-w=
rap;background-color:transparent"> in the direction of the program flow the=
n 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:'Courier New=
';color:rgb(0,0,0);white-space:pre-wrap;background-color:transparent">g=
oto</span><span style=3D"font-size:15px;font-family:Arial;color:rgb(0,0,0);=
white-space:pre-wrap;background-color:transparent"> passes </span><span sty=
le=3D"font-size:15px;font-family:'Courier New';color:rgb(0,0,0);whi=
te-space:pre-wrap;background-color:transparent">delete local</span><span st=
yle=3D"font-size:15px;font-family:Arial;color:rgb(0,0,0);white-space:pre-wr=
ap;background-color:transparent"> it must also pass the point of declaratio=
n of the name.</span></p><br><p dir=3D"ltr" style=3D"line-height:1.15;margi=
n-top:0pt;margin-bottom:0pt"><span style=3D"font-size:15px;font-family:Aria=
l;color:rgb(0,0,0);white-space:pre-wrap;background-color:transparent">Optio=
nal: After </span><span style=3D"font-size:15px;font-family:'Courier Ne=
w';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:rg=
b(0,0,0);white-space:pre-wrap;background-color:transparent"> the name is fr=
ee for reuse in a new variable declaration.</span></p><span><font color=3D"=
#888888"><h1 dir=3D"ltr" style=3D"line-height:1.15;margin-top:10pt;margin-b=
ottom:0pt"><br></h1></font></span></span></div></div></div><span><font colo=
r=3D"#888888"><div><div class=3D"h5">
<p></p>
-- <br>
<br>
--- <br>
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals" group.<br></div></div>
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a>std-proposal...@<u></u>isocpp.org</a>.<br>
To post to this group, send email to <a>std-pr...@isocpp.org</a>.<span clas=
s=3D""><br>
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/" target=3D"_blank">http://groups.google.com/a/<u></u>isocpp.=
org/group/std-<u></u>proposals/</a>.<br>
</span></font></span></blockquote></div><br></div>
</blockquote></div></div></div></div><div class=3D""><div class=3D"h5">
<p></p>
-- <br>
<br>
--- <br>
You received this message because you are subscribed to the Google Groups &=
quot;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"mailto:std-proposals+unsubscribe@isocpp.org" target=3D"_=
blank">std-proposals+unsubscribe@isocpp.org</a>.<br>
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org" target=3D"_blank">std-proposals@isocpp.org</a>.<br>
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/" target=3D"_blank">http://groups.google.com/a/isocpp.org/gro=
up/std-proposals/</a>.<br>
</div></div></blockquote></div><br></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" 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 />
--001a11c340ee5037230505734af2--
.
Author: David Krauss <potswa@gmail.com>
Date: Wed, 15 Oct 2014 04:55:59 -0700 (PDT)
Raw View
------=_Part_5324_1950081730.1413374159825
Content-Type: text/plain; charset=UTF-8
On Wednesday, October 15, 2014 6:06:53 PM UTC+8, Andrew Tomazos wrote:
>
> Sorry, I should have actually read your proposal - specifically I think:
>
> {
>
> auto file = file_open_rlock("data_snippet");
>
> auto blob = file.fetch_all();
>
> file.close();
>
Not only is it more readable, it's more correct. Relying on destructors for
side effects demands that they ignore any failures. Explicitly flushing and
closing a file or a connection before it goes out of scope gives a
confirmation of success that implicit destructor cleanup does not. (At
least, that can't safely happen until uncaught_exception gets fixed.)
Likewise, it's cleaner if a destructor can treat an open state as a
failure, and avoid flushing or such side effects for the sake of safety
over convenience.
--
---
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/.
------=_Part_5324_1950081730.1413374159825
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr"><br><br>On Wednesday, October 15, 2014 6:06:53 PM UTC+8, A=
ndrew Tomazos wrote:<blockquote class=3D"gmail_quote" style=3D"margin: 0;ma=
rgin-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><div dir=
=3D"ltr">Sorry, I should have actually read your proposal - specifically I =
think:<div><br></div><div><p dir=3D"ltr" style=3D"font-family:arial,sans-se=
rif;font-size:13px;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-s=
pace:pre-wrap;background-color:transparent">{</span></p><p dir=3D"ltr" styl=
e=3D"font-family:arial,sans-serif;font-size:13px;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">auto file =3D file_open_rlock("data_snippet"<wbr>);</span><=
/p><p dir=3D"ltr" style=3D"font-family:arial,sans-serif;font-size:13px;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:p=
re-wrap;background-color:transparent">auto blob =3D file.fetch_all();</span=
></p><p dir=3D"ltr" style=3D"font-family:arial,sans-serif;font-size:13px;li=
ne-height:1.15;margin-top:0pt;margin-bottom:0pt;text-indent:36pt"><span sty=
le=3D"font-size:15px;font-family:'Courier New';color:rgb(0,0,0);white-space=
:pre-wrap;background-color:transparent">file.close();</span></p></div></div=
></blockquote><div><br>Not only is it more readable, it's more correct. Rel=
ying on destructors for side effects demands that they ignore any failures.=
Explicitly flushing and closing a file or a connection before it goes out =
of scope gives a confirmation of success that implicit destructor cleanup d=
oes not. (At least, that can't safely happen until uncaught_exception gets =
fixed.)<br><br>Likewise, it's cleaner if a destructor can treat an open sta=
te as a failure, and avoid flushing or such side effects for the sake of sa=
fety over convenience.<br><br></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" 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_5324_1950081730.1413374159825--
.
Author: Pablo Oliva <pabloliva87@gmail.com>
Date: Wed, 15 Oct 2014 10:37:18 -0300
Raw View
--001a11348cbc0fc1e30505763bbe
Content-Type: text/plain; charset=UTF-8
How is this different from the discussion labeled "*[std-proposals] Local
variables that overstay their welcome*", by Matthew Fioravante, from last
August?
2014-10-15 8:55 GMT-03:00 David Krauss <potswa@gmail.com>:
>
>
> On Wednesday, October 15, 2014 6:06:53 PM UTC+8, Andrew Tomazos wrote:
>>
>> Sorry, I should have actually read your proposal - specifically I think:
>>
>> {
>>
>> auto file = file_open_rlock("data_snippet");
>>
>> auto blob = file.fetch_all();
>>
>> file.close();
>>
>
> Not only is it more readable, it's more correct. Relying on destructors
> for side effects demands that they ignore any failures. Explicitly flushing
> and closing a file or a connection before it goes out of scope gives a
> confirmation of success that implicit destructor cleanup does not. (At
> least, that can't safely happen until uncaught_exception gets fixed.)
>
> Likewise, it's cleaner if a destructor can treat an open state as a
> failure, and avoid flushing or such side effects for the sake of safety
> over convenience.
>
> --
>
> ---
> 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/.
>
--
---
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/.
--001a11348cbc0fc1e30505763bbe
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">How is this different from the discussion labeled "<i=
><span style=3D"font-family:arial,sans-serif">[</span><span class=3D"" styl=
e=3D"font-family:arial,sans-serif">std</span><span style=3D"font-family:ari=
al,sans-serif">-propo</span><span style=3D"font-family:arial,sans-serif">sa=
ls] Local variables that overstay their welcome</span></i>", by Matthe=
w Fioravante, from last August?</div><div class=3D"gmail_extra"><br><div cl=
ass=3D"gmail_quote">2014-10-15 8:55 GMT-03:00 David Krauss <span dir=3D"ltr=
"><<a href=3D"mailto:potswa@gmail.com" target=3D"_blank">potswa@gmail.co=
m</a>></span>:<br><blockquote class=3D"gmail_quote" style=3D"margin:0 0 =
0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir=3D"ltr"><span =
class=3D""><br><br>On Wednesday, October 15, 2014 6:06:53 PM UTC+8, Andrew =
Tomazos wrote:<blockquote class=3D"gmail_quote" style=3D"margin:0;margin-le=
ft:0.8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir=3D"ltr">Sorr=
y, I should have actually read your proposal - specifically I think:<div><b=
r></div><div><p dir=3D"ltr" style=3D"font-family:arial,sans-serif;font-size=
:13px;line-height:1.15;margin-top:0pt;margin-bottom:0pt"><span style=3D"fon=
t-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"=
font-family:arial,sans-serif;font-size:13px;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:transparent">auto file =3D file_open_rlock("data_snippet"<u=
></u>);</span></p><p dir=3D"ltr" style=3D"font-family:arial,sans-serif;font=
-size:13px;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:r=
gb(0,0,0);white-space:pre-wrap;background-color:transparent">auto blob =3D =
file.fetch_all();</span></p><p dir=3D"ltr" style=3D"font-family:arial,sans-=
serif;font-size:13px;line-height:1.15;margin-top:0pt;margin-bottom:0pt;text=
-indent:36pt"><span style=3D"font-size:15px;font-family:'Courier New=
9;;color:rgb(0,0,0);white-space:pre-wrap;background-color:transparent">file=
..close();</span></p></div></div></blockquote></span><div><br>Not only is it=
more readable, it's more correct. Relying on destructors for side effe=
cts demands that they ignore any failures. Explicitly flushing and closing =
a file or a connection before it goes out of scope gives a confirmation of =
success that implicit destructor cleanup does not. (At least, that can'=
t safely happen until uncaught_exception gets fixed.)<br><br>Likewise, it&#=
39;s cleaner if a destructor can treat an open state as a failure, and avoi=
d flushing or such side effects for the sake of safety over convenience.<br=
><br></div></div><div class=3D"HOEnZb"><div class=3D"h5">
<p></p>
-- <br>
<br>
--- <br>
You received this message because you are subscribed to the Google Groups &=
quot;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"mailto:std-proposals+unsubscribe@isocpp.org" target=3D"_=
blank">std-proposals+unsubscribe@isocpp.org</a>.<br>
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org" target=3D"_blank">std-proposals@isocpp.org</a>.<br>
Visit this group at <a href=3D"http://groups.google.com/a/isocpp.org/group/=
std-proposals/" target=3D"_blank">http://groups.google.com/a/isocpp.org/gro=
up/std-proposals/</a>.<br>
</div></div></blockquote></div><br></div>
<p></p>
-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;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"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 />
--001a11348cbc0fc1e30505763bbe--
.
Author: Michael Bruck <bruck.michael@gmail.com>
Date: Wed, 15 Oct 2014 07:58:19 -0700 (PDT)
Raw View
------=_Part_527_857056717.1413385099380
Content-Type: text/plain; charset=UTF-8
On Wednesday, October 15, 2014 1:55:59 PM UTC+2, David Krauss wrote:
>
>
>
> On Wednesday, October 15, 2014 6:06:53 PM UTC+8, Andrew Tomazos wrote:
>>
>> Sorry, I should have actually read your proposal - specifically I think:
>>
>> {
>>
>> auto file = file_open_rlock("data_snippet");
>>
>> auto blob = file.fetch_all();
>>
>> file.close();
>>
>
> Not only is it more readable, it's more correct. Relying on destructors
> for side effects demands that they ignore any failures. Explicitly flushing
> and closing a file or a connection before it goes out of scope gives a
> confirmation of success that implicit destructor cleanup does not. (At
> least, that can't safely happen until uncaught_exception gets fixed.)
>
> Likewise, it's cleaner if a destructor can treat an open state as a
> failure, and avoid flushing or such side effects for the sake of safety
> over convenience.
>
If I understand it correctly the destructor exception issue could be fixed
by the time this extension is added?
--
---
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/.
------=_Part_527_857056717.1413385099380
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr"><br><br>On Wednesday, October 15, 2014 1:55:59 PM UTC+2, D=
avid Krauss wrote:<blockquote class=3D"gmail_quote" style=3D"margin: 0;marg=
in-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><div dir=3D"=
ltr"><br><br>On Wednesday, October 15, 2014 6:06:53 PM UTC+8, Andrew Tomazo=
s wrote:<blockquote class=3D"gmail_quote" style=3D"margin:0;margin-left:0.8=
ex;border-left:1px #ccc solid;padding-left:1ex"><div dir=3D"ltr">Sorry, I s=
hould have actually read your proposal - specifically I think:<div><br></di=
v><div><p dir=3D"ltr" style=3D"font-family:arial,sans-serif;font-size:13px;=
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-space:pre-wrap;backg=
round-color:transparent">{</span></p><p dir=3D"ltr" style=3D"font-family:ar=
ial,sans-serif;font-size:13px;line-height:1.15;margin-top:0pt;margin-bottom=
:0pt;text-indent:36pt"><span style=3D"font-size:15px;font-family:'Courier N=
ew';color:rgb(0,0,0);white-space:pre-wrap;background-color:transparent">aut=
o file =3D file_open_rlock("data_snippet"<wbr>);</span></p><p dir=3D"ltr" s=
tyle=3D"font-family:arial,sans-serif;font-size:13px;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-=
color:transparent">auto blob =3D file.fetch_all();</span></p><p dir=3D"ltr"=
style=3D"font-family:arial,sans-serif;font-size:13px;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">file.close();</span></p></div></div></blockquote><div>=
<br>Not only is it more readable, it's more correct. Relying on destructors=
for side effects demands that they ignore any failures. Explicitly flushin=
g and closing a file or a connection before it goes out of scope gives a co=
nfirmation of success that implicit destructor cleanup does not. (At least,=
that can't safely happen until uncaught_exception gets fixed.)<br><br>Like=
wise, it's cleaner if a destructor can treat an open state as a failure, an=
d avoid flushing or such side effects for the sake of safety over convenien=
ce.<br></div></div></blockquote><div><br></div><div>If I understand it corr=
ectly the destructor exception issue could be fixed by the time this extens=
ion is added?<br></div><div><br></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" 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_527_857056717.1413385099380--
.
Author: Nevin Liber <nevin@eviloverlord.com>
Date: Wed, 15 Oct 2014 09:59:26 -0500
Raw View
--047d7bfced1c3d7053050577632a
Content-Type: text/plain; charset=UTF-8
On 15 October 2014 08:37, Pablo Oliva <pabloliva87@gmail.com> wrote:
> How is this different from the discussion labeled "*[std-proposals] Local
> variables that overstay their welcome*", by Matthew Fioravante, from last
> August?
>
Also, why doesn't std::experimental::optional meet your needs?
--
Nevin ":-)" Liber <mailto:nevin@eviloverlord.com> (847) 691-1404
--
---
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/.
--047d7bfced1c3d7053050577632a
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">On 15 October 2014 08:37, Pablo Oliva <span dir=3D"ltr">&l=
t;<a href=3D"mailto:pabloliva87@gmail.com" target=3D"_blank">pabloliva87@gm=
ail.com</a>></span> wrote:<br><div class=3D"gmail_extra"><div class=3D"g=
mail_quote"><blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;bo=
rder-left:1px #ccc solid;padding-left:1ex"><div dir=3D"ltr">How is this dif=
ferent from the discussion labeled "<i><span style=3D"font-family:aria=
l,sans-serif">[</span><span style=3D"font-family:arial,sans-serif">std</spa=
n><span style=3D"font-family:arial,sans-serif">-propo</span><span style=3D"=
font-family:arial,sans-serif">sals] Local variables that overstay their wel=
come</span></i>", by Matthew Fioravante, from last August?</div></bloc=
kquote><div><br></div><div>Also, why doesn't std::experimental::optiona=
l meet your needs?</div></div>-- <br>=C2=A0Nevin ":-)" Liber=C2=
=A0 <mailto:<a href=3D"mailto:nevin@eviloverlord.com" target=3D"_blank">=
nevin@eviloverlord.com</a>>=C2=A0 (847) 691-1404
</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" 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 />
--047d7bfced1c3d7053050577632a--
.
Author: Michael Bruck <bruck.michael@gmail.com>
Date: Wed, 15 Oct 2014 08:00:29 -0700 (PDT)
Raw View
------=_Part_439_468043954.1413385229841
Content-Type: text/plain; charset=UTF-8
I had not seen that thread before posting. From what I see there the
proposal focuses on making the name inaccessible while retaining the
destruction mechanism. My primary goal is to destroy the object at the site
of the delete local expression.
Michael
On Wednesday, October 15, 2014 3:37:21 PM UTC+2, Pablo Oliva wrote:
>
> How is this different from the discussion labeled "*[std-proposals] Local
> variables that overstay their welcome*", by Matthew Fioravante, from last
> August?
>
> 2014-10-15 8:55 GMT-03:00 David Krauss <pot...@gmail.com <javascript:>>:
>
>>
>>
>> On Wednesday, October 15, 2014 6:06:53 PM UTC+8, Andrew Tomazos wrote:
>>>
>>> Sorry, I should have actually read your proposal - specifically I think:
>>>
>>> {
>>>
>>> auto file = file_open_rlock("data_snippet");
>>>
>>> auto blob = file.fetch_all();
>>>
>>> file.close();
>>>
>>
>> Not only is it more readable, it's more correct. Relying on destructors
>> for side effects demands that they ignore any failures. Explicitly flushing
>> and closing a file or a connection before it goes out of scope gives a
>> confirmation of success that implicit destructor cleanup does not. (At
>> least, that can't safely happen until uncaught_exception gets fixed.)
>>
>> Likewise, it's cleaner if a destructor can treat an open state as a
>> failure, and avoid flushing or such side effects for the sake of safety
>> over convenience.
>>
>> --
>>
>> ---
>> 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-proposal...@isocpp.org <javascript:>.
>> To post to this group, send email to std-pr...@isocpp.org <javascript:>.
>> Visit this group at
>> http://groups.google.com/a/isocpp.org/group/std-proposals/.
>>
>
>
--
---
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/.
------=_Part_439_468043954.1413385229841
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr"><div><br></div>I had not seen that thread before posting. =
From what I see there the proposal focuses on making the name inaccessible =
while retaining the destruction mechanism. My primary goal is to destroy th=
e object at the site of the <font face=3D"courier new, monospace">delete lo=
cal</font> expression.<div><br></div><div>Michael<br><div><br></div><div><b=
r>On Wednesday, October 15, 2014 3:37:21 PM UTC+2, Pablo Oliva wrote:<block=
quote class=3D"gmail_quote" style=3D"margin: 0;margin-left: 0.8ex;border-le=
ft: 1px #ccc solid;padding-left: 1ex;"><div dir=3D"ltr">How is this differe=
nt from the discussion labeled "<i><span style=3D"font-family:arial,sans-se=
rif">[</span><span style=3D"font-family:arial,sans-serif">std</span><span s=
tyle=3D"font-family:arial,sans-serif">-propo</span><span style=3D"font-fami=
ly:arial,sans-serif">sals] Local variables that overstay their welcome</spa=
n></i>", by Matthew Fioravante, from last August?</div><div><br><div class=
=3D"gmail_quote">2014-10-15 8:55 GMT-03:00 David Krauss <span dir=3D"ltr">&=
lt;<a href=3D"javascript:" target=3D"_blank" gdf-obfuscated-mailto=3D"_TJ77=
gmgOQgJ" onmousedown=3D"this.href=3D'javascript:';return true;" onclick=3D"=
this.href=3D'javascript:';return true;">pot...@gmail.com</a>></span>:<br=
><blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1=
px #ccc solid;padding-left:1ex"><div dir=3D"ltr"><span><br><br>On Wednesday=
, October 15, 2014 6:06:53 PM UTC+8, Andrew Tomazos wrote:<blockquote class=
=3D"gmail_quote" style=3D"margin:0;margin-left:0.8ex;border-left:1px #ccc s=
olid;padding-left:1ex"><div dir=3D"ltr">Sorry, I should have actually read =
your proposal - specifically I think:<div><br></div><div><p dir=3D"ltr" sty=
le=3D"font-family:arial,sans-serif;font-size:13px;line-height:1.15;margin-t=
op:0pt;margin-bottom:0pt"><span style=3D"font-size:15px;font-family:'Courie=
r New';color:rgb(0,0,0);white-space:pre-wrap;background-color:transparent">=
{</span></p><p dir=3D"ltr" style=3D"font-family:arial,sans-serif;font-size:=
13px;line-height:1.15;margin-top:0pt;margin-bottom:0pt;text-indent:36pt"><s=
pan style=3D"font-size:15px;font-family:'Courier New';color:rgb(0,0,0);whit=
e-space:pre-wrap;background-color:transparent">auto file =3D file_open_rloc=
k("data_snippet"<u></u><wbr>);</span></p><p dir=3D"ltr" style=3D"font-famil=
y:arial,sans-serif;font-size:13px;line-height:1.15;margin-top:0pt;margin-bo=
ttom:0pt;text-indent:36pt"><span style=3D"font-size:15px;font-family:'Couri=
er 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"font-fam=
ily:arial,sans-serif;font-size:13px;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">file.close();</span></p></div></div></blockquote></span><div><br>Not onl=
y is it more readable, it's more correct. Relying on destructors for side e=
ffects demands that they ignore any failures. Explicitly flushing and closi=
ng a file or a connection before it goes out of scope gives a confirmation =
of success that implicit destructor cleanup does not. (At least, that can't=
safely happen until uncaught_exception gets fixed.)<br><br>Likewise, it's =
cleaner if a destructor can treat an open state as a failure, and avoid flu=
shing or such side effects for the sake of safety over convenience.<br><br>=
</div></div><div><div>
<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"=
_TJ77gmgOQgJ" 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"_TJ77gmgOQgJ" 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>
</div></div></blockquote></div><br></div>
</blockquote></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" 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_439_468043954.1413385229841--
.
Author: Michael Bruck <bruck.michael@gmail.com>
Date: Wed, 15 Oct 2014 17:11:07 +0200
Raw View
On Wed, Oct 15, 2014 at 4:59 PM, Nevin Liber <nevin@eviloverlord.com> wrote:
> On 15 October 2014 08:37, Pablo Oliva <pabloliva87@gmail.com> wrote:
>>
>> How is this different from the discussion labeled "[std-proposals] Local
>> variables that overstay their welcome", by Matthew Fioravante, from last
>> August?
>
>
> Also, why doesn't std::experimental::optional meet your needs?
It requires an extra state variable to know whether it is engaged and
code to check that state for optional destruction.
--
---
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/.
.
Author: David Krauss <potswa@gmail.com>
Date: Wed, 15 Oct 2014 08:25:45 -0700 (PDT)
Raw View
------=_Part_780_420025956.1413386745668
Content-Type: text/plain; charset=UTF-8
On Wednesday, October 15, 2014 11:11:09 PM UTC+8, Michael Bruck wrote:
>
> It requires an extra state variable to know whether it is engaged and
> code to check that state for optional destruction.
>
State variables in guards are indeed unnecessary overhead, but when the
destructor in question is heavyweight I/O, the point is mooted.
Most classes can disengage from everything without the help of optional.
Blobs can be empty, and connections can always disconnect before the object
goes out of scope.
It would be nice to let the compiler know that an object becomes trivially
destructible after a certain point in a scope, because it's been reset or
moved-from. But I've yet to see a case where the destructor really needs to
be advanced before the end-of-scope.
--
---
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/.
------=_Part_780_420025956.1413386745668
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr"><br><br>On Wednesday, October 15, 2014 11:11:09 PM UTC+8, =
Michael Bruck wrote:<blockquote class=3D"gmail_quote" style=3D"margin: 0;ma=
rgin-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;">It require=
s an extra state variable to know whether it is engaged and
<br>code to check that state for optional destruction.
<br></blockquote><div><br>State variables in guards are indeed unnecessary =
overhead, but when the destructor in question is heavyweight I/O, the point=
is mooted.<br><br>Most classes can disengage from everything without the h=
elp of optional. Blobs can be empty, and connections can always disconnect =
before the object goes out of scope.<br><br>It would be nice to let the com=
piler know that an object becomes trivially destructible after a certain po=
int in a scope, because it's been reset or moved-from. But I've yet to see =
a case where the destructor really needs to be advanced before the end-of-s=
cope.<br></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" 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_780_420025956.1413386745668--
.
Author: Nevin Liber <nevin@eviloverlord.com>
Date: Wed, 15 Oct 2014 10:31:07 -0500
Raw View
--047d7bb03afa74e9dd050577d441
Content-Type: text/plain; charset=UTF-8
On 15 October 2014 10:11, Michael Bruck <bruck.michael@gmail.com> wrote:
> It requires an extra state variable to know whether it is engaged and
> code to check that state for optional destruction.
>
How do you avoid it in code like:
auto a = GetSomething();
if (b)
delete local a;
// Do more stuff...
And if you disallow code like that, what stops the optimizer from
optimizing out the extra state variable in boost::experimental::optional?
--
Nevin ":-)" Liber <mailto:nevin@eviloverlord.com> (847) 691-1404
--
---
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/.
--047d7bb03afa74e9dd050577d441
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr"><div class=3D"gmail_extra"><br><div class=3D"gmail_quote">=
On 15 October 2014 10:11, Michael Bruck <span dir=3D"ltr"><<a href=3D"ma=
ilto:bruck.michael@gmail.com" target=3D"_blank">bruck.michael@gmail.com</a>=
></span> wrote:<br><blockquote class=3D"gmail_quote" style=3D"margin:0 0=
0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div id=3D":4rq" class=
=3D"a3s" style=3D"overflow:hidden">It requires an extra state variable to k=
now whether it is engaged and<br>
code to check that state for optional destruction.</div></blockquote><div><=
br></div><div>How do you avoid it in code like:</div><div><br></div><div>au=
to a =3D GetSomething();</div><div>if (b)=C2=A0</div><div>=C2=A0 =C2=A0 del=
ete local a;</div><div>// Do more stuff...</div><div><br></div><div>And if =
you disallow code like that, what stops the optimizer from optimizing out t=
he extra state variable in boost::experimental::optional?</div></div>-- <br=
>=C2=A0Nevin ":-)" Liber=C2=A0 <mailto:<a href=3D"mailto:nevin=
@eviloverlord.com" target=3D"_blank">nevin@eviloverlord.com</a>>=C2=A0 (=
847) 691-1404
</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" 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 />
--047d7bb03afa74e9dd050577d441--
.
Author: Michael Bruck <bruck.michael@gmail.com>
Date: Thu, 16 Oct 2014 00:31:34 -0700 (PDT)
Raw View
------=_Part_6236_170328849.1413444694209
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
On Wednesday, October 15, 2014 5:25:45 PM UTC+2, David Krauss wrote:
>
>
>
> On Wednesday, October 15, 2014 11:11:09 PM UTC+8, Michael Bruck wrote:
>>
>> It requires an extra state variable to know whether it is engaged and=20
>> code to check that state for optional destruction.=20
>>
>
> State variables in guards are indeed unnecessary overhead, but when the=
=20
> destructor in question is heavyweight I/O, the point is mooted.
>
The destructor is not heavyweight. E.g. the file destructor only releases=
=20
the lock and underlying OS handles. But I guess you can always argue that=
=20
an extra bool isn=E2=80=99t that much in relation to the rest of your code.
Apart from stack use the bool also adds to code size. In the small test=20
program that I appended below f1() compiles to 432 bytes and f2() to 294=20
bytes (i686-w64-mingw32-g++.exe -Ofast). Also the construction of optional=
=20
is not free.
> Most classes can disengage from everything without the help of optional.=
=20
> Blobs can be empty, and connections can always disconnect before the obje=
ct=20
> goes out of scope.
>
Well that is the premise of the first example in the proposal. I listed the=
=20
disadvantages I see with that.
=20
>
> It would be nice to let the compiler know that an object becomes triviall=
y=20
> destructible after a certain point in a scope, because it's been reset or=
=20
> moved-from. But I've yet to see a case where the destructor really needs =
to=20
> be advanced before the end-of-scope.
>
=20
That reflects the state of the language which lacks a means to destroy=20
local objects when the user wants to. As a result the libraries include=20
otherwise unnecessary code to soft-destroy the object and track this=20
additional state. The proposal would allow a move beyond that status quo.
#include <boost/optional.hpp>
struct S;
void foo(S *);
struct S
{
int x[64];
S(int);
~S();
};
void f1()
{
boost::optional<S> o1{0};
boost::optional<S> o2{0};
foo(o1.get_ptr());
o1.reset();
foo(o2.get_ptr());
}
/* simulate the behavior of delete local (wrong variable init order though)=
=20
*/
void f2()
{
S s2{0};
{
S s1{0};
foo(&s1);
}
foo(&s2);
}
--=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_6236_170328849.1413444694209
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">On Wednesday, October 15, 2014 5:25:45 PM UTC+2, David Kra=
uss wrote:<blockquote class=3D"gmail_quote" style=3D"margin: 0;margin-left:=
0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><div dir=3D"ltr"><br=
><br>On Wednesday, October 15, 2014 11:11:09 PM UTC+8, Michael Bruck wrote:=
<blockquote class=3D"gmail_quote" style=3D"margin:0;margin-left:0.8ex;borde=
r-left:1px #ccc solid;padding-left:1ex">It requires an extra state variable=
to know whether it is engaged and
<br>code to check that state for optional destruction.
<br></blockquote><div><br>State variables in guards are indeed unnecessary =
overhead, but when the destructor in question is heavyweight I/O, the point=
is mooted.<br></div></div></blockquote><div><br></div><div>The destructor =
is not heavyweight. E.g. the file destructor only releases the lock and und=
erlying OS handles. But I guess you can always argue that an extra bool isn=
=E2=80=99t that much in relation to the rest of your code.</div><div><br></=
div><div>Apart from stack use the bool also adds to code size. In the small=
test program that I appended below f1() compiles to 432 bytes and f2() to =
294 bytes (i686-w64-mingw32-g++.exe -Ofast). Also the construction of optio=
nal is not free.</div><div><br></div><blockquote class=3D"gmail_quote" styl=
e=3D"margin: 0;margin-left: 0.8ex;border-left: 1px #ccc solid;padding-left:=
1ex;"><div dir=3D"ltr"><div><br>Most classes can disengage from everything=
without the help of optional. Blobs can be empty, and connections can alwa=
ys disconnect before the object goes out of scope.<br></div></div></blockqu=
ote><div><br></div><div>Well that is the premise of the first example in th=
e proposal. I listed the disadvantages I see with that.</div><div> </d=
iv><blockquote class=3D"gmail_quote" style=3D"margin: 0;margin-left: 0.8ex;=
border-left: 1px #ccc solid;padding-left: 1ex;"><div dir=3D"ltr"><div><br>I=
t would be nice to let the compiler know that an object becomes trivially d=
estructible after a certain point in a scope, because it's been reset or mo=
ved-from. But I've yet to see a case where the destructor really needs to b=
e advanced before the end-of-scope.<br></div></div></blockquote><div> =
</div><div><div>That reflects the state of the language which lacks a means=
to destroy local objects when the user wants to. As a result the libraries=
include otherwise unnecessary code to soft-destroy the object and track th=
is additional state. The proposal would allow a move beyond that status quo=
..</div></div><div><br></div><div><br></div><div><div><font face=3D"courier =
new, monospace">#include <boost/optional.hpp></font></div><div><font =
face=3D"courier new, monospace"><br></font></div><div><font face=3D"courier=
new, monospace">struct S;</font></div><div><font face=3D"courier new, mono=
space">void foo(S *);</font></div><div><font face=3D"courier new, monospace=
"><br></font></div><div><font face=3D"courier new, monospace">struct S</fon=
t></div><div><font face=3D"courier new, monospace">{</font></div><div><font=
face=3D"courier new, monospace"> int x[64];</font></div><div>=
<font face=3D"courier new, monospace"> S(int);</font></div><di=
v><font face=3D"courier new, monospace"> ~S();</font></div><di=
v><font face=3D"courier new, monospace">};</font></div><div><font face=3D"c=
ourier new, monospace"><br></font></div><div><font face=3D"courier new, mon=
ospace">void f1()</font></div><div><font face=3D"courier new, monospace">{<=
/font></div><div><font face=3D"courier new, monospace"> boost:=
:optional<S> o1{0};</font></div><div><font face=3D"courier new, monos=
pace"> boost::optional<S> o2{0};</font></div><div><font =
face=3D"courier new, monospace"><br></font></div><div><font face=3D"courier=
new, monospace"> foo(o1.get_ptr());</font></div><div><font fa=
ce=3D"courier new, monospace"> o1.reset();</font></div><div><f=
ont face=3D"courier new, monospace"> foo(o2.get_ptr());</font>=
</div><div><font face=3D"courier new, monospace">}</font></div><div><font f=
ace=3D"courier new, monospace"><br></font></div><div><font face=3D"courier =
new, monospace">/* simulate the behavior of delete local (wrong variable in=
it order though) */</font></div><div><font face=3D"courier new, monospace">=
void f2()</font></div><div><font face=3D"courier new, monospace">{</font></=
div><div><font face=3D"courier new, monospace"> S s2{0};</font=
></div><div><font face=3D"courier new, monospace"> {</font></d=
iv><div><font face=3D"courier new, monospace"><span class=3D"Apple-tab-span=
" style=3D"white-space:pre"> </span>S s1{0};</font></div><div><font face=3D=
"courier new, monospace"><br></font></div><div><font face=3D"courier new, m=
onospace"><span class=3D"Apple-tab-span" style=3D"white-space:pre"> </span>=
foo(&s1);</font></div><div><font face=3D"courier new, monospace"> =
}</font></div><div><font face=3D"courier new, monospace"><br></font=
></div><div><font face=3D"courier new, monospace"> foo(&s2=
);</font></div><div><font face=3D"courier new, monospace">}</font></div></d=
iv><div><br></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" 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_6236_170328849.1413444694209--
.
Author: Michael Bruck <bruck.michael@gmail.com>
Date: Thu, 16 Oct 2014 00:34:12 -0700 (PDT)
Raw View
------=_Part_2506_1166667568.1413444852777
Content-Type: text/plain; charset=UTF-8
On Wednesday, October 15, 2014 5:31:50 PM UTC+2, Nevin ":-)" Liber wrote:
>
>
> On 15 October 2014 10:11, Michael Bruck <bruck....@gmail.com <javascript:>
> > wrote:
>
>> It requires an extra state variable to know whether it is engaged and
>> code to check that state for optional destruction.
>>
>
> How do you avoid it in code like:
>
> auto a = GetSomething();
> if (b)
> delete local a;
> // Do more stuff...
>
>
This would not be valid code under the proposal.
And if you disallow code like that, what stops the optimizer from
> optimizing out the extra state variable in boost::experimental::optional?
>
It can do so only in the most simple cases. If any exception can be thrown
after the optional has been reset then the compiler has a hard time seeing
that optimization. (I have attached a small test case in the reply to David
Krause that shows that)
And the compiler can not reuse the stack space of the value inside optional
if its address has been used.
Apart from that use-after-reset() is a runtime issue (get_ptr() returns
nullptr) while use-after-delete-local is a compile-time error.
--
---
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/.
------=_Part_2506_1166667568.1413444852777
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr"><br>On Wednesday, October 15, 2014 5:31:50 PM UTC+2, Nevin=
":-)" Liber wrote:<blockquote class=3D"gmail_quote" style=3D"margin: 0;mar=
gin-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><div dir=3D=
"ltr"><div><br><div class=3D"gmail_quote">On 15 October 2014 10:11, Michael=
Bruck <span dir=3D"ltr"><<a href=3D"javascript:" target=3D"_blank" gdf-=
obfuscated-mailto=3D"_qXq9rzpkioJ" onmousedown=3D"this.href=3D'javascript:'=
;return true;" onclick=3D"this.href=3D'javascript:';return true;">bruck....=
@gmail.com</a>></span> wrote:<br><blockquote class=3D"gmail_quote" style=
=3D"margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div sty=
le=3D"overflow:hidden">It requires an extra state variable to know whether =
it is engaged and<br>
code to check that state for optional destruction.</div></blockquote><div><=
br></div><div>How do you avoid it in code like:</div><div><br></div><div>au=
to a =3D GetSomething();</div><div>if (b) </div><div> del=
ete local a;</div><div>// Do more stuff...</div><div><br></div></div></div>=
</div></blockquote><div><br></div><div><div>This would not be valid code un=
der the proposal.</div></div><div><br></div><blockquote class=3D"gmail_quot=
e" style=3D"margin: 0;margin-left: 0.8ex;border-left: 1px #ccc solid;paddin=
g-left: 1ex;"><div dir=3D"ltr"><div><div class=3D"gmail_quote"><div>And if =
you disallow code like that, what stops the optimizer from optimizing out t=
he extra state variable in boost::experimental::optional?</div></div></div>=
</div></blockquote><div><br></div><div><div>It can do so only in the most s=
imple cases. If any exception can be thrown after the optional has been res=
et then the compiler has a hard time seeing that optimization. (I have atta=
ched a small test case in the reply to David Krause that shows that)</div><=
div><br></div><div>And the compiler can not reuse the stack space of the va=
lue inside optional if its address has been used.</div><div><br></div><div>=
Apart from that use-after-reset() is a runtime issue (get_ptr() returns nul=
lptr) while use-after-delete-local is a compile-time error.</div></div><div=
><br></div><blockquote class=3D"gmail_quote" style=3D"margin: 0;margin-left=
: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;">
</blockquote></div>
<p></p>
-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;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"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_2506_1166667568.1413444852777--
.
Author: oliver.j.nadler@gmail.com
Date: Thu, 23 Oct 2014 09:49:49 -0700 (PDT)
Raw View
------=_Part_712_230168811.1414082989224
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
Michael,
I've read your proposal. I think that it is a good one and that it is even=
=20
necessary to be implemented one day.
I want to share with you my points of view with the intention to help you=
=20
improve it.
So far I know this is very strong related with stack unwinding. Stack works=
=20
with LIFO (Last input, last output). The objects are deleted in the inverse=
=20
order they were created. For example:
#include<iostream>
using namespace std;
struct A{
unsigned a;
A(unsigned aa):a(aa){};
~A(){
cout<<"deleting "<<a<<endl;
}
};
int main(){
A a(0),b(1),c(2);
}//delete local c,b,a;
What you are proposing is to allow the handling of the stack. Variables=20
deleted should be pushed out from the stack. You called "}" as operator.
I would call it unwind operator
delete local would be an operator composed by two words. Instead of delete=
=20
local, it could be more accurate: unwind operator.
This operator should be able to be overloaded with and without specific=20
arguments.
void operator unwind(){}
void operator unwind(int a,int b){}
int main(){
string a;
unwind a;
string b;
unwind(0,1)b;
}
(Every time that the stack unwinds implicitly a variable or object, the=20
operator without specific arguments would be called if present).
For example:
{
string a;
}//implicit call to string::operator unwind() if present
I think that even with conditional unwindings the code should be compiled,=
=20
only the operator should behaves different.
For example (without conditional unwindings):
int main(){
string a;//use 0x01
unwind a;//free 0x01
string b;//use 0x01
unwind b;//free 0x01
string c;//use 0x01
}//implicit unwind c and free 0x01
With conditional unwindings:
int main(){
string a;//use 0x01
if(condition)unwind a;//destroy the object, call the unwind operator if=
=20
present and remove 'a' from stack
string b;//use 0x02
b=3Da;//To read an unwinded variable should cause undefined behaviour
unwind b;//free 0x02
string c;//use 0x02
}//unwind c and free 0x02
It is important to also consider the *return* and *throw* keywords in your=
=20
proposal.
int main(){
string a;
string b;
string c;
unwind a;
throw 0;//implicit unwind of c and b
return 0;//implicit unwind of c and b
}
You wrote:
delete local file, reply;
I think that this would also be a good syntax for the *delete* and=20
*delete[]* operators:
delete[]a,b,c,d;
But this is not possible because the comma operator has other purpose, for=
=20
example:
delete[]a=3Da-1,a,
delete[]b=3Db+5,b,
delete[]c=3Dc*3,c,
delete[]--d,d;
The comma operator has the purpose to help the value to be calculated and=
=20
it will always be considered only the most right expression, so:
delete[]a,b,c,d;
Only deletes d;
So I think that insted of:
delete local file,replay;
It should be:
delete local file,delete local replay;
Or:
unwind file,unwind replay;
Regards,
PF, ncomputers
Am Mittwoch, 15. Oktober 2014 02:14:42 UTC-5 schrieb Michael Bruck:
>
> 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-def=
ined 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 sometimes=
=20
> overlap in complex ways.
>
> Sometimes objects hold expensive resources and especially with programmin=
g=20
> patterns like threading or resumable functions the resources can remain=
=20
> blocked long after use if other functions in the same block require a lon=
g=20
> 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 variable=
=20
> declaration.
>
>
--=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_712_230168811.1414082989224
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">Michael,<br><br>I've read your proposal. I think that it i=
s a good one and that it is even necessary to be implemented one day.<br><b=
r>I want to share with you my points of view with the intention to help you=
improve it.<br><br>So far I know this is very strong related with stack un=
winding. Stack works with LIFO (Last input, last output). The objects are d=
eleted in the inverse order they were created. For example:<br><br><div cla=
ss=3D"prettyprint" style=3D"background-color: rgb(250, 250, 250); border-co=
lor: rgb(187, 187, 187); border-style: solid; border-width: 1px; word-wrap:=
break-word;"><code class=3D"prettyprint"><div class=3D"subprettyprint"><sp=
an style=3D"color: #800;" class=3D"styled-by-prettify">#include</span><span=
style=3D"color: #080;" class=3D"styled-by-prettify"><iostream></span=
><span style=3D"color: #000;" class=3D"styled-by-prettify"><br></span><span=
style=3D"color: #008;" class=3D"styled-by-prettify">using</span><span styl=
e=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"colo=
r: #008;" class=3D"styled-by-prettify">namespace</span><span style=3D"color=
: #000;" class=3D"styled-by-prettify"> std</span><span style=3D"color: #660=
;" class=3D"styled-by-prettify">;</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"><br><br></span><span style=3D"color: #008;" class=
=3D"styled-by-prettify">struct</span><span style=3D"color: #000;" class=3D"=
styled-by-prettify"> A</span><span style=3D"color: #660;" class=3D"styled-b=
y-prettify">{</span><span style=3D"color: #000;" class=3D"styled-by-prettif=
y"><br> </span><span style=3D"color: #008;" class=3D"styled-by=
-prettify">unsigned</span><span style=3D"color: #000;" class=3D"styled-by-p=
rettify"> a</span><span style=3D"color: #660;" class=3D"styled-by-prettify"=
>;</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>&nbs=
p; A</span><span style=3D"color: #660;" class=3D"styled-by-prettify"=
>(</span><span style=3D"color: #008;" class=3D"styled-by-prettify">unsigned=
</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> aa</span>=
<span style=3D"color: #660;" class=3D"styled-by-prettify">):</span><span st=
yle=3D"color: #000;" class=3D"styled-by-prettify">a</span><span style=3D"co=
lor: #660;" class=3D"styled-by-prettify">(</span><span style=3D"color: #000=
;" class=3D"styled-by-prettify">aa</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">){};</span><span style=3D"color: #000;" class=3D"st=
yled-by-prettify"><br> </span><span style=3D"color: #660;" cla=
ss=3D"styled-by-prettify">~</span><span style=3D"color: #000;" class=3D"sty=
led-by-prettify">A</span><span style=3D"color: #660;" class=3D"styled-by-pr=
ettify">(){</span><span style=3D"color: #000;" class=3D"styled-by-prettify"=
><br> cout</span><span style=3D"color: #660;" cl=
ass=3D"styled-by-prettify"><<</span><span style=3D"color: #080;" clas=
s=3D"styled-by-prettify">"deleting "</span><span style=3D"color: #660;" cla=
ss=3D"styled-by-prettify"><<</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify">a</span><span style=3D"color: #660;" class=3D"style=
d-by-prettify"><<</span><span style=3D"color: #000;" class=3D"styled-=
by-prettify">endl</span><span style=3D"color: #660;" class=3D"styled-by-pre=
ttify">;</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><b=
r> </span><span style=3D"color: #660;" class=3D"styled-by-pret=
tify">}</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><br></span><s=
pan style=3D"color: #008;" class=3D"styled-by-prettify">int</span><span sty=
le=3D"color: #000;" class=3D"styled-by-prettify"> main</span><span style=3D=
"color: #660;" class=3D"styled-by-prettify">(){</span><span style=3D"color:=
#000;" class=3D"styled-by-prettify"><br> A a</span><span styl=
e=3D"color: #660;" class=3D"styled-by-prettify">(</span><span style=3D"colo=
r: #066;" class=3D"styled-by-prettify">0</span><span style=3D"color: #660;"=
class=3D"styled-by-prettify">),</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify">b</span><span style=3D"color: #660;" class=3D"style=
d-by-prettify">(</span><span style=3D"color: #066;" class=3D"styled-by-pret=
tify">1</span><span style=3D"color: #660;" class=3D"styled-by-prettify">),<=
/span><span style=3D"color: #000;" class=3D"styled-by-prettify">c</span><sp=
an style=3D"color: #660;" class=3D"styled-by-prettify">(</span><span style=
=3D"color: #066;" class=3D"styled-by-prettify">2</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: #800;" class=3D"style=
d-by-prettify">//delete local c,b,a;</span><span style=3D"color: #000;" cla=
ss=3D"styled-by-prettify"><br></span></div></code></div><br>What you are pr=
oposing is to allow the handling of the stack. Variables deleted should be =
pushed out from the stack. You called "}" as operator.<br><br>I would call =
it <span style=3D"background-color: rgb(238, 238, 238);"><font face=3D"cour=
ier new,monospace">unwind operator</font></span><br><br><span style=3D"colo=
r: rgb(0, 0, 0);"><span style=3D"background-color: rgb(238, 238, 238);"><sp=
an style=3D"font-family: courier new,monospace;">delete local</span></span>=
</span>would be an operator composed by two words. Instead of <span style=
=3D"font-family: courier new,monospace;"><span style=3D"background-color: r=
gb(238, 238, 238);">delete local</span></span>, it could be more accurate: =
<span style=3D"font-family: courier new,monospace;"><span style=3D"backgrou=
nd-color: rgb(238, 238, 238);">unwind operator</span></span>.<br><br>This o=
perator should be able to be overloaded with and without specific arguments=
..<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"><div class=3D"su=
bprettyprint"><span style=3D"color: #008;" class=3D"styled-by-prettify">voi=
d</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><=
span style=3D"color: #008;" class=3D"styled-by-prettify">operator</span><sp=
an style=3D"color: #000;" class=3D"styled-by-prettify"> unwind</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"co=
lor: #008;" class=3D"styled-by-prettify">void</span><span style=3D"color: #=
000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #008;" cla=
ss=3D"styled-by-prettify">operator</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"> unwind</span><span style=3D"color: #660;" class=3D=
"styled-by-prettify">(</span><span style=3D"color: #008;" class=3D"styled-b=
y-prettify">int</span><span style=3D"color: #000;" class=3D"styled-by-prett=
ify"> a</span><span style=3D"color: #660;" class=3D"styled-by-prettify">,</=
span><span style=3D"color: #008;" class=3D"styled-by-prettify">int</span><s=
pan style=3D"color: #000;" class=3D"styled-by-prettify"> b</span><span styl=
e=3D"color: #660;" class=3D"styled-by-prettify">){}</span><span style=3D"co=
lor: #000;" class=3D"styled-by-prettify"><br><br></span><span style=3D"colo=
r: #008;" class=3D"styled-by-prettify">int</span><span style=3D"color: #000=
;" class=3D"styled-by-prettify"> main</span><span style=3D"color: #660;" cl=
ass=3D"styled-by-prettify">(){</span><span style=3D"color: #000;" class=3D"=
styled-by-prettify"><br> </span><span style=3D"color: #008;" c=
lass=3D"styled-by-prettify">string</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"> a</span><span style=3D"color: #660;" class=3D"styl=
ed-by-prettify">;</span><span style=3D"color: #000;" class=3D"styled-by-pre=
ttify"><br> unwind a</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">;</span><span style=3D"color: #000;" class=3D"style=
d-by-prettify"><br> </span><span style=3D"color: #008;" class=
=3D"styled-by-prettify">string</span><span style=3D"color: #000;" class=3D"=
styled-by-prettify"> b</span><span style=3D"color: #660;" class=3D"styled-b=
y-prettify">;</span><span style=3D"color: #000;" class=3D"styled-by-prettif=
y"><br> unwind</span><span style=3D"color: #660;" class=3D"sty=
led-by-prettify">(</span><span style=3D"color: #066;" class=3D"styled-by-pr=
ettify">0</span><span style=3D"color: #660;" class=3D"styled-by-prettify">,=
</span><span style=3D"color: #066;" class=3D"styled-by-prettify">1</span><s=
pan style=3D"color: #660;" class=3D"styled-by-prettify">)</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify">b</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"style=
d-by-prettify"><br></span></div></code></div><br>(Every time that the stack=
unwinds implicitly a variable or object, the operator without specific arg=
uments would be called if present).<br><br>For example:<br><br><div class=
=3D"prettyprint" style=3D"background-color: rgb(250, 250, 250); border-colo=
r: rgb(187, 187, 187); border-style: solid; border-width: 1px; word-wrap: b=
reak-word;"><code class=3D"prettyprint"><div class=3D"subprettyprint"><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: #008;" class=3D"styled-by-prettify">string</span><span styl=
e=3D"color: #000;" class=3D"styled-by-prettify"> a</span><span style=3D"col=
or: #660;" class=3D"styled-by-prettify">;</span><span style=3D"color: #000;=
" class=3D"styled-by-prettify"><br></span><span style=3D"color: #660;" clas=
s=3D"styled-by-prettify">}</span><span style=3D"color: #800;" class=3D"styl=
ed-by-prettify">//implicit call to string::operator unwind() if present</sp=
an><span style=3D"color: #000;" class=3D"styled-by-prettify"><br></span></d=
iv></code></div><br>I think that even with conditional unwindings the code =
should be compiled, only the operator should behaves different.<br><br>For =
example (without conditional unwindings):<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;"><cod=
e 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-prettify"> main</span><span style=3D"color: #660;" clas=
s=3D"styled-by-prettify">(){</span><span style=3D"color: #000;" class=3D"st=
yled-by-prettify"><br> </span><span style=3D"color: #008;" cla=
ss=3D"styled-by-prettify">string</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"> a</span><span style=3D"color: #660;" class=3D"styl=
ed-by-prettify">;</span><span style=3D"color: #800;" class=3D"styled-by-pre=
ttify">//use 0x01</span><span style=3D"color: #000;" class=3D"styled-=
by-prettify"><br> unwind a</span><span style=3D"color: #660;" =
class=3D"styled-by-prettify">;</span><span style=3D"color: #800;" class=3D"=
styled-by-prettify">//free 0x01</span><span style=3D"color: #000;" class=3D=
"styled-by-prettify"><br> </span><span style=3D"color: #008;" =
class=3D"styled-by-prettify">string</span><span style=3D"color: #000;" clas=
s=3D"styled-by-prettify"> b</span><span style=3D"color: #660;" class=3D"sty=
led-by-prettify">;</span><span style=3D"color: #800;" class=3D"styled-by-pr=
ettify">//use 0x01</span><span style=3D"color: #000;" class=3D"styled=
-by-prettify"><br> unwind b</span><span style=3D"color: #660;"=
class=3D"styled-by-prettify">;</span><span style=3D"color: #800;" class=3D=
"styled-by-prettify">//free 0x01</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"><br> </span><span style=3D"color: #008=
;" class=3D"styled-by-prettify">string</span><span style=3D"color: #000;" c=
lass=3D"styled-by-prettify"> c</span><span style=3D"color: #660;" class=3D"=
styled-by-prettify">;</span><span style=3D"color: #800;" class=3D"styled-by=
-prettify">//use 0x01</span><span style=3D"color: #000;" class=3D"sty=
led-by-prettify"><br></span><span style=3D"color: #660;" class=3D"styled-by=
-prettify">}</span><span style=3D"color: #800;" class=3D"styled-by-prettify=
">//implicit unwind c and free 0x01</span><span style=3D"color: #000;" clas=
s=3D"styled-by-prettify"><br></span></div></code></div><br>With conditional=
unwindings:<br><br><div class=3D"prettyprint" style=3D"background-color: r=
gb(250, 250, 250); border-color: rgb(187, 187, 187); border-style: solid; b=
order-width: 1px; word-wrap: break-word;"><code class=3D"prettyprint"><div =
class=3D"subprettyprint"><span style=3D"color: #008;" class=3D"styled-by-pr=
ettify">int</span><span style=3D"color: #000;" class=3D"styled-by-prettify"=
> main</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: #008;" class=3D"styled-by-prettify">str=
ing</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> a</spa=
n><span style=3D"color: #660;" class=3D"styled-by-prettify">;</span><span s=
tyle=3D"color: #800;" class=3D"styled-by-prettify">//use 0x01</span><=
span style=3D"color: #000;" class=3D"styled-by-prettify"><br> =
</span><span style=3D"color: #008;" class=3D"styled-by-prettify">if</span><=
span style=3D"color: #660;" class=3D"styled-by-prettify">(</span><span styl=
e=3D"color: #000;" class=3D"styled-by-prettify">condition</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">)</span><span style=3D"color=
: #000;" class=3D"styled-by-prettify">unwind a</span><span style=3D"color: =
#660;" class=3D"styled-by-prettify">;</span><span style=3D"color: #800;" cl=
ass=3D"styled-by-prettify">//destroy the object, call the unwind operator i=
f present and remove 'a' from stack</span><span style=3D"color: #000;" clas=
s=3D"styled-by-prettify"><br> </span><span style=3D"color: #00=
8;" class=3D"styled-by-prettify">string</span><span style=3D"color: #000;" =
class=3D"styled-by-prettify"> b</span><span style=3D"color: #660;" class=3D=
"styled-by-prettify">;</span><span style=3D"color: #800;" class=3D"styled-b=
y-prettify">//use 0x02</span><span style=3D"color: #000;" class=3D"st=
yled-by-prettify"><br> b</span><span style=3D"color: #660;" cl=
ass=3D"styled-by-prettify">=3D</span><span style=3D"color: #000;" class=3D"=
styled-by-prettify">a</span><span style=3D"color: #660;" class=3D"styled-by=
-prettify">;</span><span style=3D"color: #800;" class=3D"styled-by-prettify=
">//To read an unwinded variable should cause undefined behaviour</span><sp=
an style=3D"color: #000;" class=3D"styled-by-prettify"><br> un=
wind b</span><span style=3D"color: #660;" class=3D"styled-by-prettify">;</s=
pan><span style=3D"color: #800;" class=3D"styled-by-prettify">//free 0x02</=
span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br> &=
nbsp; </span><span style=3D"color: #008;" class=3D"styled-by-prettify">stri=
ng</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> c</span=
><span style=3D"color: #660;" class=3D"styled-by-prettify">;</span><span st=
yle=3D"color: #800;" class=3D"styled-by-prettify">//use 0x02</span><s=
pan style=3D"color: #000;" class=3D"styled-by-prettify"><br></span><span st=
yle=3D"color: #660;" class=3D"styled-by-prettify">}</span><span style=3D"co=
lor: #800;" class=3D"styled-by-prettify">//unwind c and free 0x02</span><sp=
an style=3D"color: #000;" class=3D"styled-by-prettify"><br></span></div></c=
ode></div><br>It is important to also consider the <span style=3D"backgroun=
d-color: rgb(238, 238, 238);"><b><span style=3D"font-family: courier new,mo=
nospace;">return</span></b></span> and <span style=3D"background-color: rgb=
(238, 238, 238);"><b><span style=3D"font-family: courier new,monospace;">th=
row</span></b></span> keywords in your proposal.<br><br><div class=3D"prett=
yprint" style=3D"background-color: rgb(250, 250, 250); border-color: rgb(18=
7, 187, 187); border-style: solid; border-width: 1px; word-wrap: break-word=
;"><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-prettify"> main</span><span style=3D"color: #660=
;" class=3D"styled-by-prettify">(){</span><span style=3D"color: #000;" clas=
s=3D"styled-by-prettify"><br> </span><span style=3D"color: #00=
8;" class=3D"styled-by-prettify">string</span><span style=3D"color: #000;" =
class=3D"styled-by-prettify"> a</span><span style=3D"color: #660;" class=3D=
"styled-by-prettify">;</span><span style=3D"color: #000;" class=3D"styled-b=
y-prettify"><br> </span><span style=3D"color: #008;" class=3D"=
styled-by-prettify">string</span><span style=3D"color: #000;" class=3D"styl=
ed-by-prettify"> b</span><span style=3D"color: #660;" class=3D"styled-by-pr=
ettify">;</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><=
br> </span><span style=3D"color: #008;" class=3D"styled-by-pre=
ttify">string</span><span style=3D"color: #000;" class=3D"styled-by-prettif=
y"> c</span><span style=3D"color: #660;" class=3D"styled-by-prettify">;</sp=
an><span style=3D"color: #000;" class=3D"styled-by-prettify"><br> &nb=
sp; unwind a</span><span style=3D"color: #660;" class=3D"styled-by-prettify=
">;</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>&nb=
sp; </span><span style=3D"color: #008;" class=3D"styled-by-prettify"=
>throw</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </s=
pan><span style=3D"color: #066;" class=3D"styled-by-prettify">0</span><span=
style=3D"color: #660;" class=3D"styled-by-prettify">;</span><span style=3D=
"color: #800;" class=3D"styled-by-prettify">//implicit unwind of c and b</s=
pan><span style=3D"color: #000;" class=3D"styled-by-prettify"><br> &n=
bsp; </span><span style=3D"color: #008;" class=3D"styled-by-prettify">retur=
n</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><=
span style=3D"color: #066;" class=3D"styled-by-prettify">0</span><span styl=
e=3D"color: #660;" class=3D"styled-by-prettify">;</span><span style=3D"colo=
r: #800;" class=3D"styled-by-prettify">//implicit unwind of c and b</span><=
span style=3D"color: #000;" class=3D"styled-by-prettify"><br></span><span s=
tyle=3D"color: #660;" class=3D"styled-by-prettify">}</span><span style=3D"c=
olor: #000;" class=3D"styled-by-prettify"><br></span></div></code></div><br=
>You wrote:<br><br><blockquote style=3D"margin: 0px 0px 0px 0.8ex; border-l=
eft: 1px solid rgb(204, 204, 204); padding-left: 1ex;" class=3D"gmail_quote=
"><span><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">d=
elete local file, reply;</span></span></blockquote><div><br>I think that th=
is would also be a good syntax for the <span style=3D"background-color: rgb=
(238, 238, 238);"><span style=3D"font-family: courier new,monospace;"><b>de=
lete</b></span></span> and <span style=3D"background-color: rgb(238, 238, 2=
38);"><span style=3D"font-family: courier new,monospace;"><b>delete[]</b></=
span></span> operators:<br><br><div class=3D"prettyprint" style=3D"backgrou=
nd-color: rgb(250, 250, 250); border-color: rgb(187, 187, 187); border-styl=
e: solid; border-width: 1px; word-wrap: break-word;"><code class=3D"prettyp=
rint"><div class=3D"subprettyprint"><span style=3D"color: #008;" class=3D"s=
tyled-by-prettify">delete</span><span style=3D"color: #660;" class=3D"style=
d-by-prettify">[]</span><span style=3D"color: #000;" class=3D"styled-by-pre=
ttify">a</span><span style=3D"color: #660;" class=3D"styled-by-prettify">,<=
/span><span style=3D"color: #000;" class=3D"styled-by-prettify">b</span><sp=
an style=3D"color: #660;" class=3D"styled-by-prettify">,</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify">c</span><span style=3D"color=
: #660;" class=3D"styled-by-prettify">,</span><span style=3D"color: #000;" =
class=3D"styled-by-prettify">d</span><span style=3D"color: #660;" class=3D"=
styled-by-prettify">;</span><span style=3D"color: #000;" class=3D"styled-by=
-prettify"><br></span></div></code></div><br>But this is not possible becau=
se the comma operator has other purpose, for example:<br></div><br><div cla=
ss=3D"prettyprint" style=3D"background-color: rgb(250, 250, 250); border-co=
lor: rgb(187, 187, 187); border-style: solid; border-width: 1px; word-wrap:=
break-word;"><code class=3D"prettyprint"><div class=3D"subprettyprint"><sp=
an style=3D"color: #008;" class=3D"styled-by-prettify">delete</span><span s=
tyle=3D"color: #660;" class=3D"styled-by-prettify">[]</span><span style=3D"=
color: #000;" class=3D"styled-by-prettify">a</span><span style=3D"color: #6=
60;" class=3D"styled-by-prettify">=3D</span><span style=3D"color: #000;" cl=
ass=3D"styled-by-prettify">a</span><span style=3D"color: #660;" class=3D"st=
yled-by-prettify">-</span><span style=3D"color: #066;" class=3D"styled-by-p=
rettify">1</span><span style=3D"color: #660;" class=3D"styled-by-prettify">=
,</span><span style=3D"color: #000;" class=3D"styled-by-prettify">a</span><=
span style=3D"color: #660;" class=3D"styled-by-prettify">,</span><span styl=
e=3D"color: #000;" class=3D"styled-by-prettify"><br></span><span style=3D"c=
olor: #008;" class=3D"styled-by-prettify">delete</span><span style=3D"color=
: #660;" class=3D"styled-by-prettify">[]</span><span style=3D"color: #000;"=
class=3D"styled-by-prettify">b</span><span style=3D"color: #660;" class=3D=
"styled-by-prettify">=3D</span><span style=3D"color: #000;" class=3D"styled=
-by-prettify">b</span><span style=3D"color: #660;" class=3D"styled-by-prett=
ify">+</span><span style=3D"color: #066;" class=3D"styled-by-prettify">5</s=
pan><span style=3D"color: #660;" class=3D"styled-by-prettify">,</span><span=
style=3D"color: #000;" class=3D"styled-by-prettify">b</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: #008;" =
class=3D"styled-by-prettify">delete</span><span style=3D"color: #660;" clas=
s=3D"styled-by-prettify">[]</span><span style=3D"color: #000;" class=3D"sty=
led-by-prettify">c</span><span style=3D"color: #660;" class=3D"styled-by-pr=
ettify">=3D</span><span style=3D"color: #000;" class=3D"styled-by-prettify"=
>c</span><span style=3D"color: #660;" class=3D"styled-by-prettify">*</span>=
<span style=3D"color: #066;" class=3D"styled-by-prettify">3</span><span sty=
le=3D"color: #660;" class=3D"styled-by-prettify">,</span><span style=3D"col=
or: #000;" class=3D"styled-by-prettify">c</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: #008;" class=3D"st=
yled-by-prettify">delete</span><span style=3D"color: #660;" class=3D"styled=
-by-prettify">[]--</span><span style=3D"color: #000;" class=3D"styled-by-pr=
ettify">d</span><span style=3D"color: #660;" class=3D"styled-by-prettify">,=
</span><span style=3D"color: #000;" class=3D"styled-by-prettify">d</span><s=
pan style=3D"color: #660;" class=3D"styled-by-prettify">;</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"><br></span></div></code></di=
v><br>The comma operator has the purpose to help the value to be calculated=
and it will always be considered only the most right expression, so:<br><b=
r><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"><div class=3D"subpretty=
print"><span style=3D"color: #008;" class=3D"styled-by-prettify">delete</sp=
an><span style=3D"color: #660;" class=3D"styled-by-prettify">[]</span><span=
style=3D"color: #000;" class=3D"styled-by-prettify">a</span><span style=3D=
"color: #660;" class=3D"styled-by-prettify">,</span><span style=3D"color: #=
000;" class=3D"styled-by-prettify">b</span><span style=3D"color: #660;" cla=
ss=3D"styled-by-prettify">,</span><span style=3D"color: #000;" class=3D"sty=
led-by-prettify">c</span><span style=3D"color: #660;" class=3D"styled-by-pr=
ettify">,</span><span style=3D"color: #000;" class=3D"styled-by-prettify">d=
</span><span style=3D"color: #660;" class=3D"styled-by-prettify">;</span></=
div></code></div><br>Only deletes d;<br><br>So I think that insted of:<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"><div class=3D"subprett=
yprint"><span style=3D"color: #008;" class=3D"styled-by-prettify">delete</s=
pan><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span=
style=3D"color: #008;" class=3D"styled-by-prettify">local</span><span styl=
e=3D"color: #000;" class=3D"styled-by-prettify"> file</span><span style=3D"=
color: #660;" class=3D"styled-by-prettify">,</span><span style=3D"color: #0=
00;" class=3D"styled-by-prettify">replay</span><span style=3D"color: #660;"=
class=3D"styled-by-prettify">;</span><span style=3D"color: #000;" class=3D=
"styled-by-prettify"><br></span></div></code></div><br>It should be:<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; w=
ord-wrap: break-word;"><code class=3D"prettyprint"><div class=3D"subprettyp=
rint"><span style=3D"color: #008;" class=3D"styled-by-prettify">delete</spa=
n><span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span s=
tyle=3D"color: #008;" class=3D"styled-by-prettify">local</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"> file</span><span style=3D"c=
olor: #660;" class=3D"styled-by-prettify">,</span><span style=3D"color: #00=
8;" class=3D"styled-by-prettify">delete</span><span style=3D"color: #000;" =
class=3D"styled-by-prettify"> </span><span style=3D"color: #008;" class=3D"=
styled-by-prettify">local</span><span style=3D"color: #000;" class=3D"style=
d-by-prettify"> replay</span><span style=3D"color: #660;" class=3D"styled-b=
y-prettify">;</span><span style=3D"color: #000;" class=3D"styled-by-prettif=
y"><br></span></div></code></div><br>Or:<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"><div class=3D"subprettyprint"><span style=3D"color: =
#000;" class=3D"styled-by-prettify">unwind file</span><span style=3D"color:=
#660;" class=3D"styled-by-prettify">,</span><span style=3D"color: #000;" c=
lass=3D"styled-by-prettify">unwind replay</span><span style=3D"color: #660;=
" class=3D"styled-by-prettify">;</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"><br></span></div></code></div><br>Regards,<br><br>P=
F, ncomputers<br><br>Am Mittwoch, 15. Oktober 2014 02:14:42 UTC-5 schrieb M=
ichael Bruck:<blockquote class=3D"gmail_quote" style=3D"margin: 0;margin-le=
ft: 0.8ex;border-left: 1px #ccc solid;padding-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">Hello 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-height:1.15;margin-top:0pt;margin-bo=
ttom: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"line-height:1.15;margin-top:0pt;ma=
rgin-bottom:0pt"><br></p><p dir=3D"ltr" style=3D"line-height:1.15;margin-to=
p:0pt;margin-bottom:0pt"><br></p><p dir=3D"ltr" style=3D"line-height:1.15;m=
argin-top:0pt;margin-bottom:0pt"><br></p><p dir=3D"ltr" style=3D"line-heigh=
t:1.15;margin-top:0pt;margin-bottom:0pt">Regards,</p><p dir=3D"ltr" style=
=3D"line-height:1.15;margin-top:0pt;margin-bottom:0pt">Michael</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"><=
span style=3D"font-size:28px;font-family:'Trebuchet MS';color:rgb(0,0,0);wh=
ite-space:pre-wrap;background-color:transparent"><br></span></p><p dir=3D"l=
tr" 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;backgr=
ound-color:transparent"><font size=3D"4">Deleting local variables</font></s=
pan></p><h1 dir=3D"ltr" style=3D"line-height:1.15;margin-top:10pt;margin-bo=
ttom:0pt"><span style=3D"font-family:'Trebuchet 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-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 introdu=
ces a way to end the scope of a variable before its enclosing block ends.</=
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:'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;te=
xt-indent:36pt"><span style=3D"font-size:15px;font-family:'Courier New';col=
or:rgb(0,0,0);white-space:pre-wrap;background-color:transparent">std::strin=
g foo, bar;</span></p><p dir=3D"ltr" style=3D"line-height:1.15;margin-top:0=
pt;margin-bottom:0pt;text-indent:36pt"><span style=3D"font-size:15px;font-f=
amily:'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;f=
ont-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:15=
px;font-family:'Courier New';color:rgb(0,0,0);white-space:pre-wrap;backgrou=
nd-color:transparent"> </span><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">local</span><span style=3D"font-size:15px;font-family:=
'Courier New';color:rgb(0,0,0);white-space:pre-wrap;background-color:transp=
arent"> foo, bar;</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-=
color:transparent">...</span></p><p dir=3D"ltr" style=3D"line-height:1.15;m=
argin-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-color:transp=
arent">}</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:rg=
b(0,0,0);white-space:pre-wrap;background-color:transparent"><font size=3D"4=
">Motivation</font></span></h1><p dir=3D"ltr" style=3D"line-height:1.15;mar=
gin-top:0pt;margin-bottom:0pt"><span style=3D"font-size:15px;font-family:Ar=
ial;color:rgb(0,0,0);white-space:pre-wrap;background-color:transparent">The=
=E2=80=9C} operator=E2=80=9D is powerful but but comes with a pre-defined =
destruction order which is not suitable for all applications. In real world=
programs the desired scopes of objects are not always cleanly nested but s=
ometimes overlap in complex ways.</span></p><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">Sometimes objects hold expensive resources and especially with pr=
ogramming patterns like threading or resumable functions the resources can =
remain blocked long after use if other functions in the same block require =
a long time to complete.</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-f=
amily:Arial;color:rgb(0,0,0);white-space:pre-wrap;background-color:transpar=
ent">This leads to programming patterns that try to mitigate this problem i=
n suboptimal ways. A typical approach looks like:</span></p><br><p dir=3D"l=
tr" 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-space:p=
re-wrap;background-color:transparent">{</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);white-spac=
e:pre-wrap;background-color:transparent">auto file =3D file_open_rlock("dat=
a_snippet"<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-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:36p=
t"><span style=3D"font-size:15px;font-family:'Courier New';color:rgb(0,0,0)=
;white-space:pre-wrap;background-color:transparent">file.close();</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"font-size:15px;font-family:'Courier Ne=
w';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" sty=
le=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);whi=
te-space:pre-wrap;background-color:transparent">conn.send(blob);</span></p>=
<p dir=3D"ltr" style=3D"line-height:1.15;margin-top:0pt;margin-bottom:0pt;t=
ext-indent:36pt"><span style=3D"font-size:15px;font-family:'Courier New';co=
lor:rgb(0,0,0);white-space:pre-wrap;background-color:transparent">blob.dest=
roy();</span></p><p dir=3D"ltr" style=3D"line-height:1.15;margin-top:0pt;ma=
rgin-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:trans=
parent">auto reply =3D conn.fetch_reply();</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">conn.disconnect();</span></p>=
<br><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">auto =
file2 =3D file_create("output");</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.write(reply);</span></p><p dir=3D"l=
tr" 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-color:transparent">reply.destroy();</sp=
an></p><p dir=3D"ltr" style=3D"line-height:1.15;margin-top:0pt;margin-botto=
m: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:transparent">fi=
le2.close();</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 N=
ew';color:rgb(0,0,0);white-space:pre-wrap;background-color:transparent">}</=
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:Arial;color:rgb(0,0,=
0);white-space:pre-wrap;background-color: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"list-style-type:disc;font-size:15px;fo=
nt-family:Arial;color:rgb(0,0,0);vertical-align:baseline;background-color:t=
ransparent"><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-c=
olor:transparent">The library needs to provide a function that releases exp=
ensive resources in addition to the destructor.</span></p></li><li dir=3D"l=
tr" style=3D"list-style-type:disc;font-size:15px;font-family:Arial;color:rg=
b(0,0,0);vertical-align:baseline;background-color:transparent"><p dir=3D"lt=
r" 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 l=
ibrary needs to keep track of the additional state in which resources are f=
reed 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;margin-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></li><li dir=3D"ltr" style=3D"list-st=
yle-type:disc;font-size:15px;font-family:Arial;color:rgb(0,0,0);vertical-al=
ign:baseline;background-color:transparent"><p dir=3D"ltr" style=3D"line-hei=
ght:1.15;margin-top:0pt;margin-bottom:0pt"><span style=3D"font-size:15px;wh=
ite-space:pre-wrap;background-color:transparent">The neutered object still =
lingers in some form on the stack until the end of the scope.</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 compiler can not diagnose at compile time when such an already =
neutered object is used accidentally due to code rewrite etc.</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">Diagnostics and other interactions that are tied to the destruction=
occur far removed in time from the time the object actually falls out of u=
se.</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 p=
roposal would allow for the following code:</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-space:pre-wrap;b=
ackground-color:transparent">{</span></p><p dir=3D"ltr" style=3D"line-heigh=
t:1.15;margin-top:0pt;margin-bottom:0pt;text-indent:36pt"><span style=3D"fo=
nt-size:15px;font-family:'Courier New';color:rgb(0,0,0);white-space:pre-wra=
p;background-color:transparent">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-indent:36pt"><span style=3D"font-size:15px;font-fami=
ly:'Courier New';color:rgb(0,0,0);white-space:pre-wrap;background-color:tra=
nsparent">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);font-wei=
ght:bold;white-space:pre-wrap;background-color:transparent">delete local fi=
le;</span></p><br><p dir=3D"ltr" style=3D"line-height:1.15;margin-top:0pt;m=
argin-bottom:0pt;text-indent:36pt"><span style=3D"font-size:15px;font-famil=
y:'Courier New';color:rgb(0,0,0);white-space:pre-wrap;background-color:tran=
sparent">auto conn =3D connect_to_peer("192.128.0.1")<wbr>;</span></p><p di=
r=3D"ltr" style=3D"line-height:1.15;margin-top:0pt;margin-bottom:0pt;text-i=
ndent:36pt"><span style=3D"font-size:15px;font-family:'Courier New';color:r=
gb(0,0,0);white-space:pre-wrap;background-color:transparent">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:'Co=
urier New';color:rgb(0,0,0);font-weight:bold;white-space:pre-wrap;backgroun=
d-color:transparent">delete local 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);white-spac=
e:pre-wrap;background-color:transparent">auto reply =3D conn.fetch_reply();=
</span></p><p dir=3D"ltr" style=3D"line-height:1.15;margin-top:0pt;margin-b=
ottom:0pt;text-indent:36pt"><span style=3D"font-size:15px;font-family:'Cour=
ier 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;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">auto file =3D file_create("outpu=
t");</span></p><p dir=3D"ltr" style=3D"line-height:1.15;margin-top:0pt;marg=
in-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:transpa=
rent">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-siz=
e:15px;font-family:'Courier New';color:rgb(0,0,0);font-weight:bold;white-sp=
ace:pre-wrap;background-color:transparent">delete local file, reply;</span>=
</p><p dir=3D"ltr" style=3D"line-height:1.15;margin-top:0pt;margin-bottom:0=
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><br><h1 di=
r=3D"ltr" style=3D"line-height:1.15;margin-top:10pt;margin-bottom:0pt"><spa=
n style=3D"font-family:'Trebuchet MS';color:rgb(0,0,0);white-space:pre-wrap=
;background-color:transparent"><font size=3D"4">Details</font></span></h1><=
br><p dir=3D"ltr" style=3D"line-height:1.15;margin-top:0pt;margin-bottom:0p=
t"><span style=3D"font-size:15px;font-family:Arial;color:rgb(0,0,0);white-s=
pace:pre-wrap;background-color:transparent">Unlike the regular </span><span=
style=3D"font-size:15px;font-family:'Courier New';color:rgb(0,0,0);white-s=
pace:pre-wrap;background-color:transparent">delete</span><span style=3D"fon=
t-size:15px;font-family:Arial;color:rgb(0,0,0);white-space:pre-wrap;backgro=
und-color:transparent"> expression the argument is not a pointer but rather=
a list of variable or function parameter names.</span></p><br><p dir=3D"lt=
r" 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">Variables in the enclosing scope cannot be de=
leted from within selection statements (</span><span style=3D"font-size:15p=
x;font-family:'Courier New';color:rgb(0,0,0);white-space:pre-wrap;backgroun=
d-color:transparent">if</span><span style=3D"font-size:15px;font-family:Ari=
al;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:pre-wrap;background-color:transparent">switch</span><span st=
yle=3D"font-size:15px;font-family:Arial;color:rgb(0,0,0);white-space:pre-wr=
ap;background-color:transparent">), iteration statements (</span><span styl=
e=3D"font-size:15px;font-family:'Courier 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-co=
lor:transparent">, </span><span style=3D"font-size:15px;font-family:'Courie=
r New';color:rgb(0,0,0);white-space:pre-wrap;background-color:transparent">=
do</span><span style=3D"font-size:15px;font-family:Arial;color:rgb(0,0,0);w=
hite-space:pre-wrap;background-color:transparent">, </span><span style=3D"f=
ont-size:15px;font-family:'Courier New';color:rgb(0,0,0);white-space:pre-wr=
ap;background-color:transparent">for</span><span style=3D"font-size:15px;fo=
nt-family:Arial;color:rgb(0,0,0);white-space:pre-wrap;background-color:tran=
sparent">), </span><span style=3D"font-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;font-family:Arial;color:rgb(0,0,0);white=
-space:pre-wrap;background-color:transparent"> clauses or other conditional=
ly executed code.</span></p><br><p dir=3D"ltr" style=3D"line-height:1.15;ma=
rgin-top:0pt;margin-bottom:0pt"><span style=3D"font-size:15px;font-family:A=
rial;color:rgb(0,0,0);white-space:pre-wrap;background-color:transparent">Wh=
en </span><span style=3D"font-size:15px;font-family:'Courier New';color:rgb=
(0,0,0);white-space:pre-wrap;background-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-siz=
e:15px;font-family:'Courier New';color:rgb(0,0,0);white-space:pre-wrap;back=
ground-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:tr=
ansparent"> in the direction of the program flow then it deletes the object=
in the same way as when crossing =E2=80=9C}=E2=80=9D. When </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">goto</span><span style=3D"font-siz=
e:15px;font-family:Arial;color:rgb(0,0,0);white-space:pre-wrap;background-c=
olor:transparent"> passes </span><span style=3D"font-size:15px;font-family:=
'Courier New';color:rgb(0,0,0);white-space:pre-wrap;background-color:transp=
arent">delete local</span><span style=3D"font-size:15px;font-family:Arial;c=
olor:rgb(0,0,0);white-space:pre-wrap;background-color:transparent"> it must=
also pass the point of declaration of the name.</span></p><br><p dir=3D"lt=
r" 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">Optional: After </span><span style=3D"font-si=
ze:15px;font-family:'Courier New';color:rgb(0,0,0);white-space:pre-wrap;bac=
kground-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:t=
ransparent"> the name is free for reuse in a new variable declaration.</spa=
n></p><h1 dir=3D"ltr" style=3D"line-height:1.15;margin-top:10pt;margin-bott=
om:0pt"><br></h1></span></div></blockquote></div>
<p></p>
-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;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"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_712_230168811.1414082989224--
.
Author: contact@ncomputers.org
Date: Thu, 23 Oct 2014 09:58:24 -0700 (PDT)
Raw View
------=_Part_113_1003421096.1414083504223
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
Michael,
I've read your proposal. I think that it is a good one and that it is even=
=20
necessary to be implemented one day.
I want to share with you my points of view with the intention to help you=
=20
improve it.
So far I know this is very strong related with stack unwinding. Stack works=
=20
with LIFO (Last input, last output). The objects are deleted in the inverse=
=20
order they were created. For example:
#include<iostream>
using namespace std;
struct A{
unsigned a;
A(unsigned aa):a(aa){};
~A(){
cout<<"deleting "<<a<<endl;
}
};
int main(){
A a(0),b(1),c(2);
}//delete local c,b,a;
What you are proposing is to allow the handling of the stack. Deleted=20
variables should be pushed out from the stack. You called "}" as operator.
I would call it unwind operator
delete local would be an operator composed by two words. Instead of delete=
=20
local, it could be more accurate: unwind operator.
This operator should be able to be overloaded with and without specific=20
arguments.
void operator unwind(){}
void operator unwind(int a,int b){}
int main(){
string a;
unwind a;
string b;
unwind(0,1)b;
}
(Every time that the stack unwinds implicitly a variable or object, the=20
operator without specific arguments would be called if present).
For example:
{
string a;
}//implicit call to string::operator unwind() if present
I think that even with conditional unwindings the code should be compiled,=
=20
only that the operator should behave different.
For example (without conditional unwindings):
i
nt main(){
string a;//use 0x01
unwind a;//free 0x01
string b;//use 0x01
unwind b;//free 0x01
string c;//use 0x01
}//implicit unwind c and free 0x01
With conditional unwindings:
int main(){
string a;//use 0x01
if(condition)unwind a;//destroy the object, call the unwind operator if=
=20
present and remove 'a' from stack
string b;//use 0x02
b=3Da;//To read an unwinded variable should cause undefined behaviour
unwind b;//free 0x02
string c;//use 0x02
}//unwind c and free 0x02
It is important to also consider the* return* and *throw* keywords in your=
=20
proposal.
int main(){
string a;
string b;
string c;
unwind a;
throw 0;//implicit unwind of c and b
return 0;//implicit unwind of c and b
}
You wrote:
delete local file, reply;
>
I think that this would also be a good syntax for the *delete* and=20
*delete[]* operators:
delete[]a,b,c,d;
But this is not possible because the comma operator has other purpose, for=
=20
example:
delete[]a=3Da-1,a,
delete[]b=3Db+5,b,
delete[]c=3Dc*3,c,
delete[]--d,d;
The comma operator has the purpose to help the value to be calculated and=
=20
it will always be considered only the most right expression:
delete[]a,b,c,d;
Only deletes d;
So I think that instead of:
delete local file,replay;
It should be:
delete local file,delete local replay;
Or:
unwind file,unwind replay;
I didn't understand this very well:
When goto crosses delete local in the direction of the program flow then it=
=20
> deletes the object in the same way as when crossing =E2=80=9C}=E2=80=9D. =
When goto passes delete=20
> local it must also pass the point of declaration of the name.
>
Can you write me please an example?=20
Regards,
PF, ncomputers
Am Mittwoch, 15. Oktober 2014 02:14:42 UTC-5 schrieb Michael Bruck:
>
> 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-def=
ined 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 sometimes=
=20
> overlap in complex ways.
>
> Sometimes objects hold expensive resources and especially with programmin=
g=20
> patterns like threading or resumable functions the resources can remain=
=20
> blocked long after use if other functions in the same block require a lon=
g=20
> 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 variable=
=20
> declaration.
>
>
--=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_113_1003421096.1414083504223
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">Michael,<br><br>I've read your proposal. I think that it i=
s a good one and that it is even necessary to be implemented one day.<br><b=
r>I want to share with you my points of view with the intention to help you=
improve it.<br><br>So far I know this is very strong related with stack un=
winding. Stack works with LIFO (Last input, last output). The objects are d=
eleted in the inverse order they were created. For example:<br><br><div cla=
ss=3D"prettyprint" style=3D"background-color: rgb(250, 250, 250); border-co=
lor: rgb(187, 187, 187); border-style: solid; border-width: 1px; word-wrap:=
break-word;"><code class=3D"prettyprint"><div class=3D"subprettyprint"><sp=
an style=3D"color: #800;" class=3D"styled-by-prettify">#include</span><span=
style=3D"color: #080;" class=3D"styled-by-prettify"><iostream></span=
><span style=3D"color: #000;" class=3D"styled-by-prettify"><br></span><span=
style=3D"color: #008;" class=3D"styled-by-prettify">using</span><span styl=
e=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"colo=
r: #008;" class=3D"styled-by-prettify">namespace</span><span style=3D"color=
: #000;" class=3D"styled-by-prettify"> std</span><span style=3D"color: #660=
;" class=3D"styled-by-prettify">;</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"><br><br></span><span style=3D"color: #008;" class=
=3D"styled-by-prettify">struct</span><span style=3D"color: #000;" class=3D"=
styled-by-prettify"> A</span><span style=3D"color: #660;" class=3D"styled-b=
y-prettify">{</span><span style=3D"color: #000;" class=3D"styled-by-prettif=
y"><br> </span><span style=3D"color: #008;" class=3D"styled-by=
-prettify">unsigned</span><span style=3D"color: #000;" class=3D"styled-by-p=
rettify"> a</span><span style=3D"color: #660;" class=3D"styled-by-prettify"=
>;</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>&nbs=
p; A</span><span style=3D"color: #660;" class=3D"styled-by-prettify"=
>(</span><span style=3D"color: #008;" class=3D"styled-by-prettify">unsigned=
</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> aa</span>=
<span style=3D"color: #660;" class=3D"styled-by-prettify">):</span><span st=
yle=3D"color: #000;" class=3D"styled-by-prettify">a</span><span style=3D"co=
lor: #660;" class=3D"styled-by-prettify">(</span><span style=3D"color: #000=
;" class=3D"styled-by-prettify">aa</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">){};</span><span style=3D"color: #000;" class=3D"st=
yled-by-prettify"><br> </span><span style=3D"color: #660;" cla=
ss=3D"styled-by-prettify">~</span><span style=3D"color: #000;" class=3D"sty=
led-by-prettify">A</span><span style=3D"color: #660;" class=3D"styled-by-pr=
ettify">(){</span><span style=3D"color: #000;" class=3D"styled-by-prettify"=
><br> cout</span><span style=3D"color: #660;" cl=
ass=3D"styled-by-prettify"><<</span><span style=3D"color: #080;" clas=
s=3D"styled-by-prettify">"deleting "</span><span style=3D"color: #660;" cla=
ss=3D"styled-by-prettify"><<</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify">a</span><span style=3D"color: #660;" class=3D"style=
d-by-prettify"><<</span><span style=3D"color: #000;" class=3D"styled-=
by-prettify">endl</span><span style=3D"color: #660;" class=3D"styled-by-pre=
ttify">;</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><b=
r> </span><span style=3D"color: #660;" class=3D"styled-by-pret=
tify">}</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><br></span><s=
pan style=3D"color: #008;" class=3D"styled-by-prettify">int</span><span sty=
le=3D"color: #000;" class=3D"styled-by-prettify"> main</span><span style=3D=
"color: #660;" class=3D"styled-by-prettify">(){</span><span style=3D"color:=
#000;" class=3D"styled-by-prettify"><br> A a</span><span styl=
e=3D"color: #660;" class=3D"styled-by-prettify">(</span><span style=3D"colo=
r: #066;" class=3D"styled-by-prettify">0</span><span style=3D"color: #660;"=
class=3D"styled-by-prettify">),</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify">b</span><span style=3D"color: #660;" class=3D"style=
d-by-prettify">(</span><span style=3D"color: #066;" class=3D"styled-by-pret=
tify">1</span><span style=3D"color: #660;" class=3D"styled-by-prettify">),<=
/span><span style=3D"color: #000;" class=3D"styled-by-prettify">c</span><sp=
an style=3D"color: #660;" class=3D"styled-by-prettify">(</span><span style=
=3D"color: #066;" class=3D"styled-by-prettify">2</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: #800;" class=3D"style=
d-by-prettify">//delete local c,b,a;</span><span style=3D"color: #000;" cla=
ss=3D"styled-by-prettify"><br></span></div></code></div><br>What you are pr=
oposing is to allow the handling of the stack. Deleted variables should be =
pushed out from the stack. You called "}" as operator.<br><br>I would call =
it <span style=3D"background-color: rgb(238, 238, 238);"><span style=3D"fon=
t-family: courier new,monospace;">unwind operator</span></span><br><br><spa=
n style=3D"background-color: rgb(238, 238, 238);"><span style=3D"font-famil=
y: courier new,monospace;">delete local</span></span> would be an operator =
composed by two words. Instead of <span style=3D"font-family: courier new,m=
onospace;"><span style=3D"background-color: rgb(238, 238, 238);">delete loc=
al</span></span>, it could be more accurate: <span style=3D"background-colo=
r: rgb(238, 238, 238);"><span style=3D"font-family: courier new,monospace;"=
>unwind operator</span></span>.<br><br>This operator should be able to be o=
verloaded with and without specific arguments.<br><br><div class=3D"prettyp=
rint" 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"c=
olor: #008;" class=3D"styled-by-prettify">void</span><span style=3D"color: =
#000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #008;" cl=
ass=3D"styled-by-prettify">operator</span><span style=3D"color: #000;" clas=
s=3D"styled-by-prettify"> unwind</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">(){}</span><span style=3D"color: #000;" class=3D"st=
yled-by-prettify"><br></span><span style=3D"color: #008;" class=3D"styled-b=
y-prettify">void</span><span style=3D"color: #000;" class=3D"styled-by-pret=
tify"> </span><span style=3D"color: #008;" class=3D"styled-by-prettify">ope=
rator</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> unwi=
nd</span><span style=3D"color: #660;" class=3D"styled-by-prettify">(</span>=
<span style=3D"color: #008;" class=3D"styled-by-prettify">int</span><span s=
tyle=3D"color: #000;" class=3D"styled-by-prettify"> a</span><span style=3D"=
color: #660;" class=3D"styled-by-prettify">,</span><span style=3D"color: #0=
08;" class=3D"styled-by-prettify">int</span><span style=3D"color: #000;" cl=
ass=3D"styled-by-prettify"> b</span><span style=3D"color: #660;" class=3D"s=
tyled-by-prettify">){}</span><span style=3D"color: #000;" class=3D"styled-b=
y-prettify"><br><br></span><span style=3D"color: #008;" class=3D"styled-by-=
prettify">int</span><span style=3D"color: #000;" class=3D"styled-by-prettif=
y"> main</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: #008;" class=3D"styled-by-prettify">s=
tring</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> a</s=
pan><span style=3D"color: #660;" class=3D"styled-by-prettify">;</span><span=
style=3D"color: #000;" class=3D"styled-by-prettify"><br> unwi=
nd a</span><span style=3D"color: #660;" class=3D"styled-by-prettify">;</spa=
n><span style=3D"color: #000;" class=3D"styled-by-prettify"><br> &nbs=
p; </span><span style=3D"color: #008;" class=3D"styled-by-prettify">string<=
/span><span style=3D"color: #000;" class=3D"styled-by-prettify"> b</span><s=
pan style=3D"color: #660;" class=3D"styled-by-prettify">;</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"><br> unwind</sp=
an><span style=3D"color: #660;" class=3D"styled-by-prettify">(</span><span =
style=3D"color: #066;" class=3D"styled-by-prettify">0</span><span style=3D"=
color: #660;" class=3D"styled-by-prettify">,</span><span style=3D"color: #0=
66;" class=3D"styled-by-prettify">1</span><span style=3D"color: #660;" clas=
s=3D"styled-by-prettify">)</span><span style=3D"color: #000;" class=3D"styl=
ed-by-prettify">b</span><span style=3D"color: #660;" class=3D"styled-by-pre=
ttify">;</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><b=
r></span><span style=3D"color: #660;" class=3D"styled-by-prettify">}</span>=
<span style=3D"color: #000;" class=3D"styled-by-prettify"><br></span></div>=
</code></div><br>(Every time that the stack unwinds implicitly a variable o=
r object, the operator without specific arguments would be called if presen=
t).<br><br>For example:<br><br><div class=3D"prettyprint" style=3D"backgrou=
nd-color: rgb(250, 250, 250); border-color: rgb(187, 187, 187); border-styl=
e: solid; border-width: 1px; word-wrap: break-word;"><code class=3D"prettyp=
rint"><div class=3D"subprettyprint"><span style=3D"color: #660;" class=3D"s=
tyled-by-prettify">{</span><span style=3D"color: #000;" class=3D"styled-by-=
prettify"><br> </span><span style=3D"color: #008;" class=3D"st=
yled-by-prettify">string</span><span style=3D"color: #000;" class=3D"styled=
-by-prettify"> a</span><span style=3D"color: #660;" class=3D"styled-by-pret=
tify">;</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: #800;" class=3D"styled-by-prettify">//implicit call to=
string::operator unwind() if present</span><span style=3D"color: #000;" cl=
ass=3D"styled-by-prettify"><br></span></div></code></div><br>I think that e=
ven with conditional unwindings the code should be compiled, only that the =
operator should behave different.<br><br>For example (without conditional u=
nwindings):<br><br>i<div class=3D"prettyprint" style=3D"background-color: r=
gb(250, 250, 250); border-color: rgb(187, 187, 187); border-style: solid; b=
order-width: 1px; word-wrap: break-word;"><code class=3D"prettyprint"><div =
class=3D"subprettyprint"><span style=3D"color: #000;" class=3D"styled-by-pr=
ettify">nt main</span><span style=3D"color: #660;" class=3D"styled-by-prett=
ify">(){</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><b=
r> </span><span style=3D"color: #008;" class=3D"styled-by-pret=
tify">string</span><span style=3D"color: #000;" class=3D"styled-by-prettify=
"> a</span><span style=3D"color: #660;" class=3D"styled-by-prettify">;</spa=
n><span style=3D"color: #800;" class=3D"styled-by-prettify">//use 0x0=
1</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br> =
; unwind a</span><span style=3D"color: #660;" class=3D"styled-by-pre=
ttify">;</span><span style=3D"color: #800;" class=3D"styled-by-prettify">//=
free 0x01</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><=
br> </span><span style=3D"color: #008;" class=3D"styled-by-pre=
ttify">string</span><span style=3D"color: #000;" class=3D"styled-by-prettif=
y"> b</span><span style=3D"color: #660;" class=3D"styled-by-prettify">;</sp=
an><span style=3D"color: #800;" class=3D"styled-by-prettify">//use 0x=
01</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>&nbs=
p; unwind b</span><span style=3D"color: #660;" class=3D"styled-by-pr=
ettify">;</span><span style=3D"color: #800;" class=3D"styled-by-prettify">/=
/free 0x01</span><span style=3D"color: #000;" class=3D"styled-by-prettify">=
<br> </span><span style=3D"color: #008;" class=3D"styled-by-pr=
ettify">string</span><span style=3D"color: #000;" class=3D"styled-by-pretti=
fy"> c</span><span style=3D"color: #660;" class=3D"styled-by-prettify">;</s=
pan><span style=3D"color: #800;" class=3D"styled-by-prettify">//use 0=
x01</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br></s=
pan><span style=3D"color: #660;" class=3D"styled-by-prettify">}</span><span=
style=3D"color: #800;" class=3D"styled-by-prettify">//implicit unwind c an=
d free 0x01</span><span style=3D"color: #000;" class=3D"styled-by-prettify"=
><br></span></div></code></div><br>With conditional unwindings:<br><br><div=
class=3D"prettyprint" style=3D"background-color: rgb(250, 250, 250); borde=
r-color: rgb(187, 187, 187); border-style: solid; border-width: 1px; word-w=
rap: break-word;"><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-prettify"> main</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">(){</span><span style=3D"col=
or: #000;" class=3D"styled-by-prettify"><br> </span><span styl=
e=3D"color: #008;" class=3D"styled-by-prettify">string</span><span style=3D=
"color: #000;" class=3D"styled-by-prettify"> a</span><span style=3D"color: =
#660;" class=3D"styled-by-prettify">;</span><span style=3D"color: #800;" cl=
ass=3D"styled-by-prettify">//use 0x01</span><span style=3D"color: #00=
0;" class=3D"styled-by-prettify"><br> </span><span style=3D"co=
lor: #008;" class=3D"styled-by-prettify">if</span><span style=3D"color: #66=
0;" class=3D"styled-by-prettify">(</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify">condition</span><span style=3D"color: #660;" class=
=3D"styled-by-prettify">)</span><span style=3D"color: #000;" class=3D"style=
d-by-prettify">unwind a</span><span style=3D"color: #660;" class=3D"styled-=
by-prettify">;</span><span style=3D"color: #800;" class=3D"styled-by-pretti=
fy">//destroy the object, call the unwind operator if present and remove 'a=
' from stack</span><span style=3D"color: #000;" class=3D"styled-by-prettify=
"><br> </span><span style=3D"color: #008;" class=3D"styled-by-=
prettify">string</span><span style=3D"color: #000;" class=3D"styled-by-pret=
tify"> b</span><span style=3D"color: #660;" class=3D"styled-by-prettify">;<=
/span><span style=3D"color: #800;" class=3D"styled-by-prettify">//use  =
;0x02</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>&=
nbsp; b</span><span style=3D"color: #660;" class=3D"styled-by-pretti=
fy">=3D</span><span style=3D"color: #000;" class=3D"styled-by-prettify">a</=
span><span style=3D"color: #660;" class=3D"styled-by-prettify">;</span><spa=
n style=3D"color: #800;" class=3D"styled-by-prettify">//To read an unwinded=
variable should cause undefined behaviour</span><span style=3D"color: #000=
;" class=3D"styled-by-prettify"><br> unwind b</span><span styl=
e=3D"color: #660;" class=3D"styled-by-prettify">;</span><span style=3D"colo=
r: #800;" class=3D"styled-by-prettify">//free 0x02</span><span style=3D"col=
or: #000;" class=3D"styled-by-prettify"><br> </span><span styl=
e=3D"color: #008;" class=3D"styled-by-prettify">string</span><span style=3D=
"color: #000;" class=3D"styled-by-prettify"> c</span><span style=3D"color: =
#660;" class=3D"styled-by-prettify">;</span><span style=3D"color: #800;" cl=
ass=3D"styled-by-prettify">//use 0x02</span><span style=3D"color: #00=
0;" class=3D"styled-by-prettify"><br></span><span style=3D"color: #660;" cl=
ass=3D"styled-by-prettify">}</span><span style=3D"color: #800;" class=3D"st=
yled-by-prettify">//unwind c and free 0x02</span><span style=3D"color: #000=
;" class=3D"styled-by-prettify"><br></span></div></code></div><br>It is imp=
ortant to also consider the<b><span style=3D"font-family: courier new,monos=
pace;"> <span style=3D"background-color: rgb(238, 238, 238);">return</span>=
</span></b> and <span style=3D"background-color: rgb(238, 238, 238);"><span=
style=3D"font-family: courier new,monospace;"><b>throw</b></span></span> k=
eywords in your proposal.<br><br><div class=3D"prettyprint" style=3D"backgr=
ound-color: rgb(250, 250, 250); border-color: rgb(187, 187, 187); border-st=
yle: solid; border-width: 1px; word-wrap: break-word;"><code class=3D"prett=
yprint"><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-prettify"> main</span><span style=3D"color: #660;" class=3D"styled-by-p=
rettify">(){</span><span style=3D"color: #000;" class=3D"styled-by-prettify=
"><br> </span><span style=3D"color: #008;" class=3D"styled-by-=
prettify">string</span><span style=3D"color: #000;" class=3D"styled-by-pret=
tify"> a</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: #008;" class=3D"styled-by-prettify">str=
ing</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> b</spa=
n><span style=3D"color: #660;" class=3D"styled-by-prettify">;</span><span s=
tyle=3D"color: #000;" class=3D"styled-by-prettify"><br> </span=
><span style=3D"color: #008;" class=3D"styled-by-prettify">string</span><sp=
an style=3D"color: #000;" class=3D"styled-by-prettify"> c</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">;</span><span style=3D"color=
: #000;" class=3D"styled-by-prettify"><br> unwind a</span><spa=
n style=3D"color: #660;" class=3D"styled-by-prettify">;</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"><br> </span><sp=
an style=3D"color: #008;" class=3D"styled-by-prettify">throw</span><span st=
yle=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"co=
lor: #066;" class=3D"styled-by-prettify">0</span><span style=3D"color: #660=
;" class=3D"styled-by-prettify">;</span><span style=3D"color: #800;" class=
=3D"styled-by-prettify">//implicit unwind of c and b</span><span style=3D"c=
olor: #000;" class=3D"styled-by-prettify"><br> </span><span st=
yle=3D"color: #008;" class=3D"styled-by-prettify">return</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color=
: #066;" class=3D"styled-by-prettify">0</span><span style=3D"color: #660;" =
class=3D"styled-by-prettify">;</span><span style=3D"color: #800;" class=3D"=
styled-by-prettify">//implicit unwind of c and b</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></div></code></div><br>You wrote:<br><br=
><blockquote style=3D"margin: 0px 0px 0px 0.8ex; border-left: 1px solid rgb=
(204, 204, 204); padding-left: 1ex;" class=3D"gmail_quote"><span><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 file, =
reply;</span></span><br></blockquote><br>I think that this would also be a =
good syntax for the <span style=3D"font-family: courier new,monospace;"><sp=
an style=3D"background-color: rgb(238, 238, 238);"><b>delete</b></span></sp=
an> and <span style=3D"font-family: courier new,monospace;"><span style=3D"=
background-color: rgb(238, 238, 238);"><b>delete[]</b></span></span> operat=
ors:<br><br><div class=3D"prettyprint" style=3D"background-color: rgb(250, =
250, 250); border-color: rgb(187, 187, 187); border-style: solid; border-wi=
dth: 1px; word-wrap: break-word;"><code class=3D"prettyprint"><div class=3D=
"subprettyprint"><span style=3D"color: #008;" class=3D"styled-by-prettify">=
delete</span><span style=3D"color: #660;" class=3D"styled-by-prettify">[]</=
span><span style=3D"color: #000;" class=3D"styled-by-prettify">a</span><spa=
n style=3D"color: #660;" class=3D"styled-by-prettify">,</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify">b</span><span style=3D"color=
: #660;" class=3D"styled-by-prettify">,</span><span style=3D"color: #000;" =
class=3D"styled-by-prettify">c</span><span style=3D"color: #660;" class=3D"=
styled-by-prettify">,</span><span style=3D"color: #000;" class=3D"styled-by=
-prettify">d</span><span style=3D"color: #660;" class=3D"styled-by-prettify=
">;</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br></s=
pan></div></code></div><br>But this is not possible because the comma opera=
tor has other purpose, for example:<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 clas=
s=3D"prettyprint"><div class=3D"subprettyprint"><span style=3D"color: #008;=
" class=3D"styled-by-prettify">delete</span><span style=3D"color: #660;" cl=
ass=3D"styled-by-prettify">[]</span><span style=3D"color: #000;" class=3D"s=
tyled-by-prettify">a</span><span style=3D"color: #660;" class=3D"styled-by-=
prettify">=3D</span><span style=3D"color: #000;" class=3D"styled-by-prettif=
y">a</span><span style=3D"color: #660;" class=3D"styled-by-prettify">-</spa=
n><span style=3D"color: #066;" class=3D"styled-by-prettify">1</span><span s=
tyle=3D"color: #660;" class=3D"styled-by-prettify">,</span><span style=3D"c=
olor: #000;" class=3D"styled-by-prettify">a</span><span style=3D"color: #66=
0;" class=3D"styled-by-prettify">,</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"><br></span><span style=3D"color: #008;" class=3D"st=
yled-by-prettify">delete</span><span style=3D"color: #660;" class=3D"styled=
-by-prettify">[]</span><span style=3D"color: #000;" class=3D"styled-by-pret=
tify">b</span><span style=3D"color: #660;" class=3D"styled-by-prettify">=3D=
</span><span style=3D"color: #000;" class=3D"styled-by-prettify">b</span><s=
pan style=3D"color: #660;" class=3D"styled-by-prettify">+</span><span style=
=3D"color: #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">b</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: #008;" class=3D"styled-by-prett=
ify">delete</span><span style=3D"color: #660;" class=3D"styled-by-prettify"=
>[]</span><span style=3D"color: #000;" class=3D"styled-by-prettify">c</span=
><span style=3D"color: #660;" class=3D"styled-by-prettify">=3D</span><span =
style=3D"color: #000;" class=3D"styled-by-prettify">c</span><span style=3D"=
color: #660;" class=3D"styled-by-prettify">*</span><span style=3D"color: #0=
66;" class=3D"styled-by-prettify">3</span><span style=3D"color: #660;" clas=
s=3D"styled-by-prettify">,</span><span style=3D"color: #000;" class=3D"styl=
ed-by-prettify">c</span><span style=3D"color: #660;" class=3D"styled-by-pre=
ttify">,</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><b=
r></span><span style=3D"color: #008;" class=3D"styled-by-prettify">delete</=
span><span style=3D"color: #660;" class=3D"styled-by-prettify">[]--</span><=
span style=3D"color: #000;" class=3D"styled-by-prettify">d</span><span styl=
e=3D"color: #660;" class=3D"styled-by-prettify">,</span><span style=3D"colo=
r: #000;" class=3D"styled-by-prettify">d</span><span style=3D"color: #660;"=
class=3D"styled-by-prettify">;</span><span style=3D"color: #000;" class=3D=
"styled-by-prettify"><br></span></div></code></div><br>The comma operator h=
as the purpose to help the value to be calculated and it will always be con=
sidered only the most right expression:<br><br><div class=3D"prettyprint" s=
tyle=3D"background-color: rgb(250, 250, 250); border-color: rgb(187, 187, 1=
87); border-style: solid; border-width: 1px; word-wrap: break-word;"><code =
class=3D"prettyprint"><div class=3D"subprettyprint"><span style=3D"color: #=
008;" class=3D"styled-by-prettify">delete</span><span style=3D"color: #660;=
" class=3D"styled-by-prettify">[]</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify">a</span><span style=3D"color: #660;" class=3D"style=
d-by-prettify">,</span><span style=3D"color: #000;" class=3D"styled-by-pret=
tify">b</span><span style=3D"color: #660;" class=3D"styled-by-prettify">,</=
span><span style=3D"color: #000;" class=3D"styled-by-prettify">c</span><spa=
n style=3D"color: #660;" class=3D"styled-by-prettify">,</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify">d</span><span style=3D"color=
: #660;" class=3D"styled-by-prettify">;</span><span style=3D"color: #000;" =
class=3D"styled-by-prettify"><br></span></div></code></div><br>Only deletes=
d;<br><br>So I think that instead of:<br><br><div class=3D"prettyprint" st=
yle=3D"background-color: rgb(250, 250, 250); border-color: rgb(187, 187, 18=
7); border-style: solid; border-width: 1px; word-wrap: break-word;"><code c=
lass=3D"prettyprint"><div class=3D"subprettyprint"><span style=3D"color: #0=
08;" class=3D"styled-by-prettify">delete</span><span style=3D"color: #000;"=
class=3D"styled-by-prettify"> </span><span style=3D"color: #008;" class=3D=
"styled-by-prettify">local</span><span style=3D"color: #000;" class=3D"styl=
ed-by-prettify"> file</span><span style=3D"color: #660;" class=3D"styled-by=
-prettify">,</span><span style=3D"color: #000;" class=3D"styled-by-prettify=
">replay</span><span style=3D"color: #660;" class=3D"styled-by-prettify">;<=
/span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br></span>=
</div></code></div><br>It should be:<br><br><div class=3D"prettyprint" styl=
e=3D"background-color: rgb(250, 250, 250); border-color: rgb(187, 187, 187)=
; border-style: solid; border-width: 1px; word-wrap: break-word;"><code cla=
ss=3D"prettyprint"><div class=3D"subprettyprint"><span style=3D"color: #008=
;" class=3D"styled-by-prettify">delete</span><span style=3D"color: #000;" c=
lass=3D"styled-by-prettify"> </span><span style=3D"color: #008;" class=3D"s=
tyled-by-prettify">local</span><span style=3D"color: #000;" class=3D"styled=
-by-prettify"> file</span><span style=3D"color: #660;" class=3D"styled-by-p=
rettify">,</span><span style=3D"color: #008;" class=3D"styled-by-prettify">=
delete</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> </s=
pan><span style=3D"color: #008;" class=3D"styled-by-prettify">local</span><=
span style=3D"color: #000;" class=3D"styled-by-prettify"> replay</span><spa=
n style=3D"color: #660;" class=3D"styled-by-prettify">;</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"><br></span></div></code></di=
v><br>Or:<br><br><div class=3D"prettyprint" style=3D"background-color: rgb(=
250, 250, 250); border-color: rgb(187, 187, 187); border-style: solid; bord=
er-width: 1px; word-wrap: break-word;"><code class=3D"prettyprint"><div cla=
ss=3D"subprettyprint"><span style=3D"color: #000;" class=3D"styled-by-prett=
ify">unwind file</span><span style=3D"color: #660;" class=3D"styled-by-pret=
tify">,</span><span style=3D"color: #000;" class=3D"styled-by-prettify">unw=
ind replay</span><span style=3D"color: #660;" class=3D"styled-by-prettify">=
;</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br></spa=
n></div></code></div><br>I didn't understand this very well:<br><br><blockq=
uote style=3D"margin: 0px 0px 0px 0.8ex; border-left: 1px solid rgb(204, 20=
4, 204); padding-left: 1ex;" class=3D"gmail_quote"><span><p dir=3D"ltr" sty=
le=3D"line-height:1.15;margin-top:0pt;margin-bottom:0pt"><span style=3D"fon=
t-size:15px;font-family:Arial;color:rgb(0,0,0);white-space:pre-wrap;backgro=
und-color:transparent">When </span><span style=3D"font-size:15px;font-famil=
y:'Courier New';color:rgb(0,0,0);white-space:pre-wrap;background-color:tran=
sparent">goto</span><span style=3D"font-size:15px;font-family:Arial;color:r=
gb(0,0,0);white-space:pre-wrap;background-color:transparent"> crosses </spa=
n><span 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"> in the direction of the program flow t=
hen 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:'Courier New';co=
lor:rgb(0,0,0);white-space:pre-wrap;background-color:transparent">goto</spa=
n><span style=3D"font-size:15px;font-family:Arial;color:rgb(0,0,0);white-sp=
ace:pre-wrap;background-color:transparent"> passes </span><span style=3D"fo=
nt-size:15px;font-family:'Courier New';color:rgb(0,0,0);white-space:pre-wra=
p;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-co=
lor:transparent"> it must also pass the point of declaration of the name.</=
span></p></span></blockquote><div><br>Can you write me please an example? <=
br></div><br>Regards,<br><br>PF, ncomputers<br><br>Am Mittwoch, 15. Oktober=
2014 02:14:42 UTC-5 schrieb Michael Bruck:<blockquote class=3D"gmail_quote=
" style=3D"margin: 0;margin-left: 0.8ex;border-left: 1px #ccc solid;padding=
-left: 1ex;"><div dir=3D"ltr"><span><p dir=3D"ltr" style=3D"line-height:1.1=
5;margin-top:0pt;margin-bottom:0pt"><span style=3D"line-height:1.15">Hello =
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;ma=
rgin-top:0pt;margin-bottom:0pt"><br></p><p dir=3D"ltr" style=3D"line-height=
:1.15;margin-top:0pt;margin-bottom:0pt">I am looking for feedback on the ou=
tline for a proposal below. I would like to know if there is interest in su=
ch a feature and any ideas on improvements.</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"lt=
r" style=3D"line-height:1.15;margin-top:0pt;margin-bottom:0pt"><br></p><p d=
ir=3D"ltr" style=3D"line-height:1.15;margin-top:0pt;margin-bottom:0pt">Rega=
rds,</p><p dir=3D"ltr" style=3D"line-height:1.15;margin-top:0pt;margin-bott=
om:0pt">Michael</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"><span style=3D"font-size:28px;font-family:'Trebu=
chet MS';color:rgb(0,0,0);white-space:pre-wrap;background-color:transparent=
"><br></span></p><p dir=3D"ltr" style=3D"line-height:1.15;margin-top:0pt;ma=
rgin-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">Deleti=
ng 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:'Trebuchet=
MS';color:rgb(0,0,0);white-space:pre-wrap;background-color:transparent"><f=
ont size=3D"4">Summary</font></span></h1><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:Arial;color:rgb(0,0,0);white-space:pre-wrap;background-color:transp=
arent">This proposal introduces a way to end the scope of a variable before=
its enclosing block ends.</span></p><br><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><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;f=
ont-family:'Courier New';color:rgb(0,0,0);white-space:pre-wrap;background-c=
olor:transparent">std::string foo, bar;</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);white-spac=
e: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"><sp=
an 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);w=
hite-space:pre-wrap;background-color:transparent"> </span><span style=3D"fo=
nt-size:15px;font-family:'Courier New';color:rgb(0,0,0);font-weight:bold;wh=
ite-space:pre-wrap;background-color:transparent">local</span><span style=3D=
"font-size:15px;font-family:'Courier New';color:rgb(0,0,0);white-space:pre-=
wrap;background-color:transparent"> foo, bar;</span></p><p dir=3D"ltr" styl=
e=3D"line-height:1.15;margin-top:0pt;margin-bottom:0pt;text-indent:36pt"><s=
pan style=3D"font-size:15px;font-family:'Courier New';color:rgb(0,0,0);whit=
e-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-space: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-fa=
mily:'Trebuchet MS';color:rgb(0,0,0);white-space:pre-wrap;background-color:=
transparent"><font size=3D"4">Motivation</font></span></h1><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:Arial;color:rgb(0,0,0);white-space:pre-wrap;backg=
round-color:transparent">The =E2=80=9C} operator=E2=80=9D is powerful but b=
ut comes with a pre-defined destruction order which is not suitable for all=
applications. In real world programs the desired scopes of objects are not=
always cleanly nested but sometimes overlap in complex ways.</span></p><p =
dir=3D"ltr" style=3D"line-height:1.15;margin-top:0pt;margin-bottom:0pt"><sp=
an style=3D"font-size:15px;font-family:Arial;color:rgb(0,0,0);white-space:p=
re-wrap;background-color:transparent">Sometimes objects hold expensive reso=
urces and especially with programming patterns like threading or resumable =
functions the resources can remain blocked long after use if other function=
s in the same block require a long time to complete.</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:Arial;color:rgb(0,0,0);white-space:pre-=
wrap;background-color:transparent">This leads to programming patterns that =
try to mitigate this problem in suboptimal ways. A typical approach looks l=
ike:</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:'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 Ne=
w';color:rgb(0,0,0);white-space:pre-wrap;background-color:transparent">auto=
file =3D file_open_rlock("data_snippet"<wbr>);</span></p><p dir=3D"ltr" st=
yle=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);wh=
ite-space:pre-wrap;background-color:transparent">auto blob =3D file.fetch_a=
ll();</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">file.close();</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"font-siz=
e:15px;font-family:'Courier New';color:rgb(0,0,0);white-space:pre-wrap;back=
ground-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-family:'Cou=
rier New';color:rgb(0,0,0);white-space:pre-wrap;background-color:transparen=
t">conn.send(blob);</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">blob.destroy();</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:p=
re-wrap;background-color:transparent">auto reply =3D conn.fetch_reply();</s=
pan></p><p dir=3D"ltr" style=3D"line-height:1.15;margin-top:0pt;margin-bott=
om: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:transparent">c=
onn.disconnect();</span></p><br><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">auto file2 =3D file_create("output");</span></p><p d=
ir=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-color:transparent">file2.write(r=
eply);</span></p><p dir=3D"ltr" style=3D"line-height:1.15;margin-top:0pt;ma=
rgin-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:trans=
parent">reply.destroy();</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-siz=
e:15px;font-family:'Courier New';color:rgb(0,0,0);white-space:pre-wrap;back=
ground-color:transparent">file2.close();</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-space:pre-wrap;backg=
round-color:transparent">}</span></p><br><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:Arial;color:rgb(0,0,0);white-space:pre-wrap;background-color:transp=
arent">There are a number of problems with this solution:</span></p><ul sty=
le=3D"margin-top:0pt;margin-bottom:0pt"><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:transparent">The library needs to provide =
a function that releases expensive resources in addition to the destructor.=
</span></p></li><li dir=3D"ltr" style=3D"list-style-type:disc;font-size:15p=
x;font-family:Arial;color:rgb(0,0,0);vertical-align:baseline;background-col=
or:transparent"><p dir=3D"ltr" style=3D"line-height:1.15;margin-top:0pt;mar=
gin-bottom:0pt"><span style=3D"font-size:15px;white-space:pre-wrap;backgrou=
nd-color:transparent">The library needs to keep track of the additional sta=
te 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-fam=
ily:Arial;color:rgb(0,0,0);vertical-align:baseline;background-color:transpa=
rent"><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:t=
ransparent">The user needs to locate such a function and understand its sem=
antics to see if it really releases enough resources.</span></p></li><li di=
r=3D"ltr" style=3D"list-style-type:disc;font-size:15px;font-family:Arial;co=
lor: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:transparent">=
The neutered object still lingers in some form on the stack until the end o=
f the scope.</span></p></li><li dir=3D"ltr" style=3D"list-style-type:disc;f=
ont-size:15px;font-family:Arial;color:rgb(0,0,0);vertical-align:baseline;ba=
ckground-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-w=
rap;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-type:disc;f=
ont-size:15px;font-family:Arial;color:rgb(0,0,0);vertical-align:baseline;ba=
ckground-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-w=
rap;background-color:transparent">Diagnostics and other interactions that a=
re tied to the destruction occur far removed in time from the time the obje=
ct 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;backgroun=
d-color:transparent">This proposal would allow for the following code:</spa=
n></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-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-in=
dent:36pt"><span style=3D"font-size:15px;font-family:'Courier New';color:rg=
b(0,0,0);white-space:pre-wrap;background-color:transparent">auto file =3D f=
ile_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"><span style=
=3D"font-size:15px;font-family:'Courier New';color:rgb(0,0,0);white-space:p=
re-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 Ne=
w';color:rgb(0,0,0);font-weight:bold;white-space:pre-wrap;background-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"><span style=
=3D"font-size:15px;font-family:'Courier New';color:rgb(0,0,0);white-space:p=
re-wrap;background-color:transparent">auto conn =3D connect_to_peer("192.12=
8.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=
-family:'Courier New';color:rgb(0,0,0);white-space:pre-wrap;background-colo=
r:transparent">conn.send(blob);</span></p><p dir=3D"ltr" style=3D"line-heig=
ht:1.15;margin-top:0pt;margin-bottom:0pt;text-indent:36pt"><span style=3D"f=
ont-size:15px;font-family:'Courier New';color:rgb(0,0,0);font-weight:bold;w=
hite-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: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">auto =
reply =3D conn.fetch_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"fon=
t-size:15px;font-family:'Courier New';color:rgb(0,0,0);font-weight:bold;whi=
te-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;margin-bottom=
:0pt;text-indent:36pt"><span style=3D"font-size:15px;font-family:'Courier N=
ew';color:rgb(0,0,0);white-space:pre-wrap;background-color:transparent">aut=
o file =3D file_create("output");</span></p><p dir=3D"ltr" style=3D"line-he=
ight: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-color:transparent">file.write(reply);</span></p><p dir=3D"l=
tr" 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">del=
ete local file, reply;</span></p><p dir=3D"ltr" style=3D"line-height:1.15;m=
argin-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-color:transp=
arent">}</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:rg=
b(0,0,0);white-space:pre-wrap;background-color:transparent"><font size=3D"4=
">Details</font></span></h1><br><p dir=3D"ltr" style=3D"line-height:1.15;ma=
rgin-top:0pt;margin-bottom:0pt"><span style=3D"font-size:15px;font-family:A=
rial;color:rgb(0,0,0);white-space:pre-wrap;background-color:transparent">Un=
like the regular </span><span style=3D"font-size:15px;font-family:'Courier =
New';color:rgb(0,0,0);white-space:pre-wrap;background-color:transparent">de=
lete</span><span style=3D"font-size:15px;font-family:Arial;color:rgb(0,0,0)=
;white-space:pre-wrap;background-color:transparent"> expression the argumen=
t is not a pointer but rather a list of variable or function parameter name=
s.</span></p><br><p dir=3D"ltr" style=3D"line-height:1.15;margin-top:0pt;ma=
rgin-bottom:0pt"><span style=3D"font-size:15px;font-family:Arial;color: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);wh=
ite-space:pre-wrap;background-color:transparent">if</span><span style=3D"fo=
nt-size:15px;font-family:Arial;color:rgb(0,0,0);white-space:pre-wrap;backgr=
ound-color:transparent">, </span><span style=3D"font-size:15px;font-family:=
'Courier New';color:rgb(0,0,0);white-space:pre-wrap;background-color:transp=
arent">switch</span><span style=3D"font-size:15px;font-family:Arial;color:r=
gb(0,0,0);white-space:pre-wrap;background-color:transparent">), iteration s=
tatements (</span><span style=3D"font-size:15px;font-family:'Courier New';c=
olor:rgb(0,0,0);white-space:pre-wrap;background-color:transparent">while</s=
pan><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-s=
ize:15px;font-family:'Courier New';color:rgb(0,0,0);white-space:pre-wrap;ba=
ckground-color:transparent">do</span><span style=3D"font-size:15px;font-fam=
ily:Arial;color:rgb(0,0,0);white-space:pre-wrap;background-color:transparen=
t">, </span><span style=3D"font-size:15px;font-family:'Courier New';color:r=
gb(0,0,0);white-space:pre-wrap;background-color:transparent">for</span><spa=
n style=3D"font-size:15px;font-family:Arial;color:rgb(0,0,0);white-space:pr=
e-wrap;background-color:transparent">), </span><span style=3D"font-size:15p=
x;font-family:'Courier New';color:rgb(0,0,0);white-space:pre-wrap;backgroun=
d-color:transparent">catch</span><span style=3D"font-size:15px;font-family:=
Arial;color:rgb(0,0,0);white-space:pre-wrap;background-color:transparent"> =
clauses or other conditionally executed code.</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:Arial;color:rgb(0,0,0);white-space:pre-wrap;back=
ground-color:transparent">When </span><span style=3D"font-size:15px;font-fa=
mily:'Courier New';color:rgb(0,0,0);white-space:pre-wrap;background-color:t=
ransparent">goto</span><span style=3D"font-size:15px;font-family:Arial;colo=
r:rgb(0,0,0);white-space:pre-wrap;background-color:transparent"> crosses </=
span><span style=3D"font-size:15px;font-family:'Courier New';color:rgb(0,0,=
0);white-space:pre-wrap;background-color:transparent">delete local</span><s=
pan style=3D"font-size:15px;font-family:Arial;color:rgb(0,0,0);white-space:=
pre-wrap;background-color:transparent"> in the direction of the program flo=
w 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:'Courier New'=
;color:rgb(0,0,0);white-space:pre-wrap;background-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"> passes </span><span 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-s=
ize:15px;font-family:Arial;color:rgb(0,0,0);white-space:pre-wrap;background=
-color:transparent"> it must also pass the point of declaration of the name=
..</span></p><br><p dir=3D"ltr" style=3D"line-height:1.15;margin-top:0pt;mar=
gin-bottom:0pt"><span style=3D"font-size:15px;font-family:Arial;color:rgb(0=
,0,0);white-space:pre-wrap;background-color:transparent">Optional: After </=
span><span style=3D"font-size:15px;font-family:'Courier New';color:rgb(0,0,=
0);white-space:pre-wrap;background-color:transparent">delete local</span><s=
pan style=3D"font-size:15px;font-family:Arial;color:rgb(0,0,0);white-space:=
pre-wrap;background-color:transparent"> the name is free for reuse in a new=
variable declaration.</span></p><h1 dir=3D"ltr" style=3D"line-height:1.15;=
margin-top:10pt;margin-bottom:0pt"><br></h1></span></div></blockquote></div=
>
<p></p>
-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;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"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_113_1003421096.1414083504223--
.
Author: corentin.schreiber@cea.fr
Date: Thu, 23 Oct 2014 10:59:48 -0700 (PDT)
Raw View
------=_Part_220_1602200295.1414087188285
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
Le mercredi 15 octobre 2014 09:14:42 UTC+2, Michael Bruck a =C3=A9crit :
>
> 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
>
I am not so fond of the idea, especially because we have been heavily=20
trained to understand and use the consequences of "operator }". This=20
created an empirical rule, according to which (if you forbid yourself to=20
"delete" pointers explicitly and respect the RAII principles) all variables=
=20
are alive and valid until the end of the scope they were declared in. It=20
would make code harder to read for me (and, I suppose, a bunch of other=20
people).
That being said, a similar situation arises with features that are actually=
=20
part of the current C++ standard. I am thinking in particular about those=
=20
people who refuse to use multiple return statements in a function. The=20
argument is that it breaks the empirical rule they imposed to themselves=20
that a function has only one end point. It breaks the flow of the program,=
=20
hence they find it less readable (I am *not* one of those). Same thing with=
=20
people that refuse to use goto, for similar reasons (I *am* one of those).=
=20
It's a matter of taste really, because 1) the standard is written so that=
=20
using these features has no undesirable side effects, and 2) in fact you=20
can write optimal code without multiple return statements, and you can=20
write optimal without goto. Much like you can write optimal code without=20
your proposal :
{
auto reply =3D []() {
auto conn =3D []() {
auto blob =3D []() {
auto file =3D file_open_rlock("data_snippet");
return file.fetch_all();
}();
auto c =3D connect_to_peer("192.128.0.1");
c.send(blob);
return c;
}();
=20
return conn.fetch_reply();
}();
auto file =3D file_create("output");
file.write(reply);
}
So what you are proposing is a cosmetic change (except for the special case=
=20
of function arguments, which was pointed out by Roman Perepelitsa, but I=20
doubt it is really useful).
I would say the points to analyze are therefore making sure that: 1) you=20
introduce no nasty side effects, 2) it will not make it easier for=20
unexperienced programmers to make mistakes, and 3) the new syntax is=20
clearer enough that it counter balances the increase in language complexity=
=20
(remember that this feature will have to be taught to people at some=20
points, think about Scott Meyer).
Although it seems at first sight that the proposal passes point 1) above,=
=20
it seems to me that this feature would only be used in very peculiar=20
situations, and I don't think it would be wise to use it as a general=20
programming habit. The problem is that it might get abused of by students,=
=20
or people coming from the C world who still have to learn that "operator }"=
=20
can do most of the job for them. My impression is therefore that it fails=
=20
point 2) and 3).
--=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_220_1602200295.1414087188285
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">Le mercredi 15 octobre 2014 09:14:42 UTC+2, Michael Bruck =
a =C3=A9crit :<blockquote class=3D"gmail_quote" style=3D"margin: 0;mar=
gin-left: 0.8ex;border-left: 1px #ccc solid;padding-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">Hello 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-bott=
om:0pt">I am looking for feedback on the outline for a proposal below. I wo=
uld like to know if there is interest in such a feature and any ideas on im=
provements.</p><p dir=3D"ltr" style=3D"line-height:1.15;margin-top:0pt;marg=
in-bottom:0pt"><br></p><p dir=3D"ltr" style=3D"line-height:1.15;margin-top:=
0pt;margin-bottom:0pt">Regards,</p><p dir=3D"ltr" style=3D"line-height:1.15=
;margin-top:0pt;margin-bottom:0pt">Michael</p></span></div></blockquote><di=
v><br>I am not so fond of the idea, especially because we have been heavily=
trained to understand and use the consequences of "operator }". This creat=
ed an empirical rule, according to which (if you forbid yourself to "delete=
" pointers explicitly and respect the RAII principles) all variables are al=
ive and valid until the end of the scope they were declared in. It would ma=
ke code harder to read for me (and, I suppose, a bunch of other people).<br=
>That being said, a similar situation arises with features that are actual=
ly part of the current C++ standard. I am thinking in particular about thos=
e people who refuse to use multiple return statements in a function. The ar=
gument is that it breaks the empirical rule they imposed to themselves that=
a function has only one end point. It breaks the flow of the program, henc=
e they find it less readable (I am <i>not</i> one of those). Same thing wit=
h people that refuse to use goto, for similar reasons (I <i>am</i> one of =
those). It's a matter of taste really, because 1) the standard is written s=
o that using these features has no undesirable side effects, and 2) in fact=
you can write optimal code without multiple return statements, and you can=
write optimal without goto. Much like you can write optimal code without y=
our proposal :<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: #660;" class=3D"styled-by-=
prettify">{</span><span style=3D"color: #000;" class=3D"styled-by-prettify"=
><br> </span><span style=3D"color: #008;" class=3D"styled-by-p=
rettify">auto</span><span style=3D"color: #000;" class=3D"styled-by-prettif=
y"> reply </span><span style=3D"color: #660;" class=3D"styled-by-prettify">=
=3D</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"> </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: #008;" class=3D"styled-by-prettify">auto</span><span s=
tyle=3D"color: #000;" class=3D"styled-by-prettify"> conn </span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">=3D</span><span style=3D"col=
or: #000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #660;=
" class=3D"styled-by-prettify">[]()</span><span style=3D"color: #000;" clas=
s=3D"styled-by-prettify"> </span><span style=3D"color: #660;" class=3D"styl=
ed-by-prettify">{</span><span style=3D"color: #000;" class=3D"styled-by-pre=
ttify"><br> </span><span style=3D"=
color: #008;" class=3D"styled-by-prettify">auto</span><span style=3D"color:=
#000;" class=3D"styled-by-prettify"> blob </span><span style=3D"color: #66=
0;" class=3D"styled-by-prettify">=3D</span><span style=3D"color: #000;" cla=
ss=3D"styled-by-prettify"> </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>&nb=
sp; </span><span style=3D"=
color: #008;" class=3D"styled-by-prettify">auto</span><span style=3D"color:=
#000;" class=3D"styled-by-prettify"> file </span><span style=3D"color: #66=
0;" class=3D"styled-by-prettify">=3D</span><span style=3D"color: #000;" cla=
ss=3D"styled-by-prettify"> file_open_rlock</span><span style=3D"color: #660=
;" class=3D"styled-by-prettify">(</span><span style=3D"color: #080;" class=
=3D"styled-by-prettify">"data_snippet"</span><span style=3D"color: #660;" c=
lass=3D"styled-by-prettify">);</span><span style=3D"color: #000;" class=3D"=
styled-by-prettify"><br> &n=
bsp; </span><span style=3D"color: #008;" class=3D"styled-by-prettify">retur=
n</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> file</sp=
an><span style=3D"color: #660;" class=3D"styled-by-prettify">.</span><span =
style=3D"color: #000;" class=3D"styled-by-prettify">fetch_all</span><span s=
tyle=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-prett=
ify">}();</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><=
br><br> </span><span style=3D"colo=
r: #008;" class=3D"styled-by-prettify">auto</span><span style=3D"color: #00=
0;" class=3D"styled-by-prettify"> c </span><span style=3D"color: #660;" cla=
ss=3D"styled-by-prettify">=3D</span><span style=3D"color: #000;" class=3D"s=
tyled-by-prettify"> connect_to_peer</span><span style=3D"color: #660;" clas=
s=3D"styled-by-prettify">(</span><span style=3D"color: #080;" class=3D"styl=
ed-by-prettify">"192.128.0.1"</span><span style=3D"color: #660;" class=3D"s=
tyled-by-prettify">);</span><span style=3D"color: #000;" class=3D"styled-by=
-prettify"><br> c</span><span styl=
e=3D"color: #660;" class=3D"styled-by-prettify">.</span><span style=3D"colo=
r: #000;" class=3D"styled-by-prettify">send</span><span style=3D"color: #66=
0;" class=3D"styled-by-prettify">(</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify">blob</span><span style=3D"color: #660;" class=3D"st=
yled-by-prettify">);</span><span style=3D"color: #000;" class=3D"styled-by-=
prettify"><br> </span><span style=
=3D"color: #008;" class=3D"styled-by-prettify">return</span><span style=3D"=
color: #000;" class=3D"styled-by-prettify"> c</span><span style=3D"color: #=
660;" class=3D"styled-by-prettify">;</span><span style=3D"color: #000;" cla=
ss=3D"styled-by-prettify"><br> </span><span styl=
e=3D"color: #660;" class=3D"styled-by-prettify">}();</span><span style=3D"c=
olor: #000;" class=3D"styled-by-prettify"><br> <=
br> </span><span style=3D"color: #008;" class=3D=
"styled-by-prettify">return</span><span style=3D"color: #000;" class=3D"sty=
led-by-prettify"> conn</span><span style=3D"color: #660;" class=3D"styled-b=
y-prettify">.</span><span style=3D"color: #000;" class=3D"styled-by-prettif=
y">fetch_reply</span><span style=3D"color: #660;" class=3D"styled-by-pretti=
fy">();</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br=
> </span><span style=3D"color: #660;" class=3D"styled-by-prett=
ify">}();</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><=
br><br> </span><span style=3D"color: #008;" class=3D"styled-by=
-prettify">auto</span><span style=3D"color: #000;" class=3D"styled-by-prett=
ify"> file </span><span style=3D"color: #660;" class=3D"styled-by-prettify"=
>=3D</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> file_=
create</span><span style=3D"color: #660;" class=3D"styled-by-prettify">(</s=
pan><span style=3D"color: #080;" class=3D"styled-by-prettify">"output"</spa=
n><span style=3D"color: #660;" class=3D"styled-by-prettify">);</span><span =
style=3D"color: #000;" class=3D"styled-by-prettify"><br> file<=
/span><span style=3D"color: #660;" class=3D"styled-by-prettify">.</span><sp=
an style=3D"color: #000;" class=3D"styled-by-prettify">write</span><span st=
yle=3D"color: #660;" class=3D"styled-by-prettify">(</span><span style=3D"co=
lor: #000;" class=3D"styled-by-prettify">reply</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><span style=3D"color: #660;" class=
=3D"styled-by-prettify">}</span></div></code></div><br>So what you are prop=
osing is a cosmetic change (except for the special case of function argumen=
ts, which was pointed out by Roman Perepelitsa, but I doubt it is really us=
eful).<br><br>I would say the points to analyze are therefore making sure =
that: 1) you introduce no nasty side effects, 2) it will not make it easier=
for unexperienced programmers to make mistakes, and 3) the new syntax is c=
learer enough that it counter balances the increase in language complexity =
(remember that this feature will have to be taught to people at some points=
, think about Scott Meyer).<br><br>Although it seems at first sight that th=
e proposal passes point 1) above, it seems to me that this feature would on=
ly be used in very peculiar situations, and I don't think it would be wise =
to use it as a general programming habit. The problem is that it might get =
abused of by students, or people coming from the C world who still have to =
learn that "operator }" can do most of the job for them. My impression is t=
herefore that it fails point 2) and 3).<br></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" 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_220_1602200295.1414087188285--
.
Author: contact@ncomputers.org
Date: Thu, 23 Oct 2014 11:20:45 -0700 (PDT)
Raw View
------=_Part_501_365591252.1414088445719
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
>
> So what you are proposing is a cosmetic change (except for the special=20
> case of function arguments, which was pointed out by Roman Perepelitsa, b=
ut=20
> I doubt it is really useful).
>
> I would say the points to analyze are therefore making sure that: 1) you=
=20
> introduce no nasty side effects, 2) it will not make it easier for=20
> unexperienced programmers to make mistakes, and 3) the new syntax is=20
> clearer enough that it counter balances the increase in language complexi=
ty=20
> (remember that this feature will have to be taught to people at some=20
> points, think about Scott Meyer).
>
I don't think that it is only a cosmetic change.
2) Inexperienced programmers usually don't know what stack unwinding is.=20
The most probably is that they won't use it.
3) I think that it would be easier to explain "operator }" with an=20
"operator unwind".
{
unsinged a;
unsigned b;
}//unwind b, unwind a;
{
unsigned a;
throw 0;//unwind a;
unsigned b;
}//if reached, unwind b;
{
unsigned a;
return 0;//unwind a;
unsigned b;
}//if reached, unwind b;
{
unsigned a;
unwind b;
unsigned a;
unwind a;
}//unwind nothing
PF, ncomputers
Am Donnerstag, 23. Oktober 2014 12:59:48 UTC-5 schrieb corentin....@cea.fr:
>
> Le mercredi 15 octobre 2014 09:14:42 UTC+2, Michael Bruck a =C3=A9crit :
>>
>> 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
>>
>
> I am not so fond of the idea, especially because we have been heavily=20
> trained to understand and use the consequences of "operator }". This=20
> created an empirical rule, according to which (if you forbid yourself to=
=20
> "delete" pointers explicitly and respect the RAII principles) all variabl=
es=20
> are alive and valid until the end of the scope they were declared in. It=
=20
> would make code harder to read for me (and, I suppose, a bunch of other=
=20
> people).
> That being said, a similar situation arises with features that are=20
> actually part of the current C++ standard. I am thinking in particular=20
> about those people who refuse to use multiple return statements in a=20
> function. The argument is that it breaks the empirical rule they imposed =
to=20
> themselves that a function has only one end point. It breaks the flow of=
=20
> the program, hence they find it less readable (I am *not* one of those).=
=20
> Same thing with people that refuse to use goto, for similar reasons (I=20
> *am* one of those). It's a matter of taste really, because 1) the=20
> standard is written so that using these features has no undesirable side=
=20
> effects, and 2) in fact you can write optimal code without multiple retur=
n=20
> statements, and you can write optimal without goto. Much like you can wri=
te=20
> optimal code without your proposal :
>
> {
> auto reply =3D []() {
> auto conn =3D []() {
> auto blob =3D []() {
> auto file =3D file_open_rlock("data_snippet");
> return file.fetch_all();
> }();
>
> auto c =3D connect_to_peer("192.128.0.1");
> c.send(blob);
> return c;
> }();
> =20
> return conn.fetch_reply();
> }();
>
> auto file =3D file_create("output");
> file.write(reply);
> }
>
> So what you are proposing is a cosmetic change (except for the special=20
> case of function arguments, which was pointed out by Roman Perepelitsa, b=
ut=20
> I doubt it is really useful).
>
> I would say the points to analyze are therefore making sure that: 1) you=
=20
> introduce no nasty side effects, 2) it will not make it easier for=20
> unexperienced programmers to make mistakes, and 3) the new syntax is=20
> clearer enough that it counter balances the increase in language complexi=
ty=20
> (remember that this feature will have to be taught to people at some=20
> points, think about Scott Meyer).
>
> Although it seems at first sight that the proposal passes point 1) above,=
=20
> it seems to me that this feature would only be used in very peculiar=20
> situations, and I don't think it would be wise to use it as a general=20
> programming habit. The problem is that it might get abused of by students=
,=20
> or people coming from the C world who still have to learn that "operator =
}"=20
> can do most of the job for them. My impression is therefore that it fails=
=20
> point 2) and 3).
>
--=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_501_365591252.1414088445719
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr"><blockquote style=3D"margin: 0px 0px 0px 0.8ex; border-lef=
t: 1px solid rgb(204, 204, 204); padding-left: 1ex;" class=3D"gmail_quote">=
So what you are proposing is a cosmetic change (except for the special=20
case of function arguments, which was pointed out by Roman Perepelitsa,=20
but I doubt it is really useful).<br><br>I would say the points to=20
analyze are therefore making sure that: 1) you introduce no nasty side=20
effects, 2) it will not make it easier for unexperienced programmers to=20
make mistakes, and 3) the new syntax is clearer enough that it counter=20
balances the increase in language complexity (remember that this feature
will have to be taught to people at some points, think about Scott=20
Meyer).<br></blockquote><div><br>I don't think that it is only a cosmetic c=
hange.<br><br>2) Inexperienced programmers usually don't know what stack un=
winding is. The most probably is that they won't use it.<br><br>3) I think =
that it would be easier to explain "operator }" with an "operator unwind".<=
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"><div class=3D"subp=
rettyprint"><span style=3D"color: #660;" class=3D"styled-by-prettify">{</sp=
an><span style=3D"color: #000;" class=3D"styled-by-prettify"><br> &nb=
sp; unsinged a</span><span style=3D"color: #660;" class=3D"styled-by-pretti=
fy">;</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>&=
nbsp; </span><span style=3D"color: #008;" class=3D"styled-by-prettif=
y">unsigned</span><span style=3D"color: #000;" class=3D"styled-by-prettify"=
> b</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: #800;" class=3D"styled-by-prettify">//unwind b, unwind a;</span><sp=
an style=3D"color: #000;" class=3D"styled-by-prettify"><br><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 =
style=3D"color: #008;" class=3D"styled-by-prettify">unsigned</span><span st=
yle=3D"color: #000;" class=3D"styled-by-prettify"> a</span><span style=3D"c=
olor: #660;" class=3D"styled-by-prettify">;</span><span style=3D"color: #00=
0;" class=3D"styled-by-prettify"><br> </span><span style=3D"co=
lor: #008;" class=3D"styled-by-prettify">throw</span><span style=3D"color: =
#000;" class=3D"styled-by-prettify"> </span><span style=3D"color: #066;" cl=
ass=3D"styled-by-prettify">0</span><span style=3D"color: #660;" class=3D"st=
yled-by-prettify">;</span><span style=3D"color: #800;" class=3D"styled-by-p=
rettify">//unwind a;</span><span style=3D"color: #000;" class=3D"styled-by-=
prettify"><br> </span><span style=3D"color: #008;" class=3D"st=
yled-by-prettify">unsigned</span><span style=3D"color: #000;" class=3D"styl=
ed-by-prettify"> b</span><span style=3D"color: #660;" class=3D"styled-by-pr=
ettify">;</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: #800;" class=3D"styled-by-prettify">//if reached, un=
wind b;</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br=
><br></span><span style=3D"color: #660;" class=3D"styled-by-prettify">{</sp=
an><span style=3D"color: #000;" class=3D"styled-by-prettify"><br> &nb=
sp; </span><span style=3D"color: #008;" class=3D"styled-by-prettify">unsign=
ed</span><span style=3D"color: #000;" class=3D"styled-by-prettify"> a</span=
><span style=3D"color: #660;" class=3D"styled-by-prettify">;</span><span st=
yle=3D"color: #000;" class=3D"styled-by-prettify"><br> </span>=
<span style=3D"color: #008;" class=3D"styled-by-prettify">return</span><spa=
n style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span style=
=3D"color: #066;" class=3D"styled-by-prettify">0</span><span style=3D"color=
: #660;" class=3D"styled-by-prettify">;</span><span style=3D"color: #800;" =
class=3D"styled-by-prettify">//unwind a;</span><span style=3D"color: #000;"=
class=3D"styled-by-prettify"><br> </span><span style=3D"color=
: #008;" class=3D"styled-by-prettify">unsigned</span><span style=3D"color: =
#000;" class=3D"styled-by-prettify"> b</span><span style=3D"color: #660;" c=
lass=3D"styled-by-prettify">;</span><span style=3D"color: #000;" class=3D"s=
tyled-by-prettify"><br></span><span style=3D"color: #660;" class=3D"styled-=
by-prettify">}</span><span style=3D"color: #800;" class=3D"styled-by-pretti=
fy">//if reached, unwind b;</span><span style=3D"color: #000;" class=3D"sty=
led-by-prettify"><br><br><br></span><span style=3D"color: #660;" class=3D"s=
tyled-by-prettify">{</span><span style=3D"color: #000;" class=3D"styled-by-=
prettify"><br> </span><span style=3D"color: #008;" class=3D"st=
yled-by-prettify">unsigned</span><span style=3D"color: #000;" class=3D"styl=
ed-by-prettify"> a</span><span style=3D"color: #660;" class=3D"styled-by-pr=
ettify">;</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><=
br> unwind b</span><span style=3D"color: #660;" class=3D"style=
d-by-prettify">;</span><span style=3D"color: #000;" class=3D"styled-by-pret=
tify"><br> </span><span style=3D"color: #008;" class=3D"styled=
-by-prettify">unsigned</span><span style=3D"color: #000;" class=3D"styled-b=
y-prettify"> a</span><span style=3D"color: #660;" class=3D"styled-by-pretti=
fy">;</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br>&=
nbsp; unwind a</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">}</s=
pan><span style=3D"color: #800;" class=3D"styled-by-prettify">//unwind noth=
ing</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br></s=
pan></div></code></div><br>PF, ncomputers<br><br></div>Am Donnerstag, 23. O=
ktober 2014 12:59:48 UTC-5 schrieb corentin....@cea.fr:<blockquote class=3D=
"gmail_quote" style=3D"margin: 0;margin-left: 0.8ex;border-left: 1px #ccc s=
olid;padding-left: 1ex;"><div dir=3D"ltr">Le mercredi 15 octobre 2014 09:14=
:42 UTC+2, Michael Bruck a =C3=A9crit :<blockquote class=3D"gmail_quot=
e" style=3D"margin:0;margin-left:0.8ex;border-left:1px #ccc solid;padding-l=
eft:1ex"><div dir=3D"ltr"><span><p dir=3D"ltr" style=3D"line-height:1.15;ma=
rgin-top:0pt;margin-bottom:0pt"><span style=3D"line-height:1.15">Hello ever=
yone,</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">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"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">Regards,</p><p dir=3D"ltr" style=
=3D"line-height:1.15;margin-top:0pt;margin-bottom:0pt">Michael</p></span></=
div></blockquote><div><br>I am not so fond of the idea, especially because =
we have been heavily trained to understand and use the consequences of "ope=
rator }". This created an empirical rule, according to which (if you forbid=
yourself to "delete" pointers explicitly and respect the RAII principles) =
all variables are alive and valid until the end of the scope they were decl=
ared in. It would make code harder to read for me (and, I suppose, a bunch =
of other people).<br>That being said, a similar situation arises with feat=
ures that are actually part of the current C++ standard. I am thinking in p=
articular about those people who refuse to use multiple return statements i=
n a function. The argument is that it breaks the empirical rule they impose=
d to themselves that a function has only one end point. It breaks the flow =
of the program, hence they find it less readable (I am <i>not</i> one of th=
ose). Same thing with people that refuse to use goto, for similar reasons =
(I <i>am</i> one of those). It's a matter of taste really, because 1) the s=
tandard is written so that using these features has no undesirable side eff=
ects, and 2) in fact you can write optimal code without multiple return sta=
tements, and you can write optimal without goto. Much like you can write op=
timal code without your proposal :<br><br><div style=3D"background-color:rg=
b(250,250,250);border-color:rgb(187,187,187);border-style:solid;border-widt=
h:1px;word-wrap:break-word"><code><div><span style=3D"color:#660">{</span><=
span style=3D"color:#000"><br> </span><span style=3D"color:#00=
8">auto</span><span style=3D"color:#000"> reply </span><span style=3D"color=
:#660">=3D</span><span style=3D"color:#000"> </span><span style=3D"color:#6=
60">[]()</span><span style=3D"color:#000"> </span><span style=3D"color:#660=
">{</span><span style=3D"color:#000"><br> </span=
><span style=3D"color:#008">auto</span><span style=3D"color:#000"> conn </s=
pan><span style=3D"color:#660">=3D</span><span style=3D"color:#000"> </span=
><span style=3D"color:#660">[]()</span><span style=3D"color:#000"> </span><=
span style=3D"color:#660">{</span><span style=3D"color:#000"><br> &nb=
sp; </span><span style=3D"color:#008">auto</spa=
n><span style=3D"color:#000"> blob </span><span style=3D"color:#660">=3D</s=
pan><span style=3D"color:#000"> </span><span style=3D"color:#660">[]()</spa=
n><span style=3D"color:#000"> </span><span style=3D"color:#660">{</span><sp=
an style=3D"color:#000"><br>  =
; </span><span style=3D"color:#008">auto</span><span style=3D"color:=
#000"> file </span><span style=3D"color:#660">=3D</span><span style=3D"colo=
r:#000"> file_open_rlock</span><span style=3D"color:#660">(</span><span sty=
le=3D"color:#080">"data_snippet"</span><span style=3D"color:#660"><wbr>);</=
span><span style=3D"color:#000"><br> &nbs=
p; </span><span style=3D"color:#008">return</span><span style=
=3D"color:#000"> file</span><span style=3D"color:#660">.</span><span style=
=3D"color:#000">fetch_all</span><span style=3D"color:#660">();</span><span =
style=3D"color:#000"><br> </span><=
span style=3D"color:#660">}();</span><span style=3D"color:#000"><br><br>&nb=
sp; </span><span style=3D"color:#008">au=
to</span><span style=3D"color:#000"> c </span><span style=3D"color:#660">=
=3D</span><span style=3D"color:#000"> connect_to_peer</span><span style=3D"=
color:#660">(</span><span style=3D"color:#080">"192.128.0.1"</span><span st=
yle=3D"color:#660">)<wbr>;</span><span style=3D"color:#000"><br> &nbs=
p; c</span><span style=3D"color:#660">.</span><=
span style=3D"color:#000">send</span><span style=3D"color:#660">(</span><sp=
an style=3D"color:#000">blob</span><span style=3D"color:#660">);</span><spa=
n style=3D"color:#000"><br> </span=
><span style=3D"color:#008">return</span><span style=3D"color:#000"> c</spa=
n><span style=3D"color:#660">;</span><span style=3D"color:#000"><br> =
</span><span style=3D"color:#660">}();</span><span sty=
le=3D"color:#000"><br> <br> =
</span><span style=3D"color:#008">return</span><span style=3D"color:=
#000"> conn</span><span style=3D"color:#660">.</span><span style=3D"color:#=
000">fetch_reply</span><span style=3D"color:#660">();</span><span style=3D"=
color:#000"><br> </span><span style=3D"color:#660">}();</span>=
<span style=3D"color:#000"><br><br> </span><span style=3D"colo=
r:#008">auto</span><span style=3D"color:#000"> file </span><span style=3D"c=
olor:#660">=3D</span><span style=3D"color:#000"> file_create</span><span st=
yle=3D"color:#660">(</span><span style=3D"color:#080">"output"</span><span =
style=3D"color:#660">);</span><span style=3D"color:#000"><br> =
file</span><span style=3D"color:#660">.</span><span style=3D"color:#000">wr=
ite</span><span style=3D"color:#660">(</span><span style=3D"color:#000">rep=
ly</span><span style=3D"color:#660">);</span><span style=3D"color:#000"><br=
></span><span style=3D"color:#660">}</span></div></code></div><br>So what y=
ou are proposing is a cosmetic change (except for the special case of funct=
ion arguments, which was pointed out by Roman Perepelitsa, but I doubt it i=
s really useful).<br><br>I would say the points to analyze are therefore m=
aking sure that: 1) you introduce no nasty side effects, 2) it will not mak=
e it easier for unexperienced programmers to make mistakes, and 3) the new =
syntax is clearer enough that it counter balances the increase in language =
complexity (remember that this feature will have to be taught to people at =
some points, think about Scott Meyer).<br><br>Although it seems at first si=
ght that the proposal passes point 1) above, it seems to me that this featu=
re would only be used in very peculiar situations, and I don't think it wou=
ld be wise to use it as a general programming habit. The problem is that it=
might get abused of by students, or people coming from the C world who sti=
ll have to learn that "operator }" can do most of the job for them. My impr=
ession is therefore that it fails point 2) and 3).<br></div></div></blockqu=
ote></div>
<p></p>
-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;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"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_501_365591252.1414088445719--
.
Author: "dgutson ." <danielgutson@gmail.com>
Date: Fri, 24 Oct 2014 00:30:53 -0300
Raw View
On Thu, Oct 23, 2014 at 3:20 PM, <contact@ncomputers.org> wrote:
>> So what you are proposing is a cosmetic change (except for the special
>> case of function arguments, which was pointed out by Roman Perepelitsa, =
but
>> I doubt it is really useful).
>>
>> I would say the points to analyze are therefore making sure that: 1) you
>> introduce no nasty side effects, 2) it will not make it easier for
>> unexperienced programmers to make mistakes, and 3) the new syntax is cle=
arer
>> enough that it counter balances the increase in language complexity
>> (remember that this feature will have to be taught to people at some poi=
nts,
>> think about Scott Meyer).
>
>
> I don't think that it is only a cosmetic change.
>
> 2) Inexperienced programmers usually don't know what stack unwinding is. =
The
> most probably is that they won't use it.
>
> 3) I think that it would be easier to explain "operator }" with an "opera=
tor
> unwind".
>
> {
> unsinged a;
> unsigned b;
> }//unwind b, unwind a;
>
> {
> unsigned a;
> throw 0;//unwind a;
> unsigned b;
> }//if reached, unwind b;
>
> {
> unsigned a;
> return 0;//unwind a;
> unsigned b;
> }//if reached, unwind b;
>
>
> {
> unsigned a;
> unwind b;
> unsigned a;
> unwind a;
> }//unwind nothing
I don't see any need of special operator since this can be achieved
with 'optional':
http://pastebin.com/Qnba9gv8
>
> PF, ncomputers
>
> Am Donnerstag, 23. Oktober 2014 12:59:48 UTC-5 schrieb corentin....@cea.f=
r:
>>
>> Le mercredi 15 octobre 2014 09:14:42 UTC+2, Michael Bruck a =C3=A9crit :
>>>
>>> Hello everyone,
>>>
>>>
>>> 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.
>>>
>>>
>>> Regards,
>>>
>>> Michael
>>
>>
>> I am not so fond of the idea, especially because we have been heavily
>> trained to understand and use the consequences of "operator }". This cre=
ated
>> an empirical rule, according to which (if you forbid yourself to "delete=
"
>> pointers explicitly and respect the RAII principles) all variables are a=
live
>> and valid until the end of the scope they were declared in. It would mak=
e
>> code harder to read for me (and, I suppose, a bunch of other people).
>> That being said, a similar situation arises with features that are
>> actually part of the current C++ standard. I am thinking in particular a=
bout
>> those people who refuse to use multiple return statements in a function.=
The
>> argument is that it breaks the empirical rule they imposed to themselves
>> that a function has only one end point. It breaks the flow of the progra=
m,
>> hence they find it less readable (I am not one of those). Same thing wit=
h
>> people that refuse to use goto, for similar reasons (I am one of those).
>> It's a matter of taste really, because 1) the standard is written so tha=
t
>> using these features has no undesirable side effects, and 2) in fact you=
can
>> write optimal code without multiple return statements, and you can write
>> optimal without goto. Much like you can write optimal code without your
>> proposal :
>>
>> {
>> auto reply =3D []() {
>> auto conn =3D []() {
>> auto blob =3D []() {
>> auto file =3D file_open_rlock("data_snippet");
>> return file.fetch_all();
>> }();
>>
>> auto c =3D connect_to_peer("192.128.0.1");
>> c.send(blob);
>> return c;
>> }();
>>
>> return conn.fetch_reply();
>> }();
>>
>> auto file =3D file_create("output");
>> file.write(reply);
>> }
>>
>> So what you are proposing is a cosmetic change (except for the special
>> case of function arguments, which was pointed out by Roman Perepelitsa, =
but
>> I doubt it is really useful).
>>
>> I would say the points to analyze are therefore making sure that: 1) you
>> introduce no nasty side effects, 2) it will not make it easier for
>> unexperienced programmers to make mistakes, and 3) the new syntax is cle=
arer
>> enough that it counter balances the increase in language complexity
>> (remember that this feature will have to be taught to people at some poi=
nts,
>> think about Scott Meyer).
>>
>> Although it seems at first sight that the proposal passes point 1) above=
,
>> it seems to me that this feature would only be used in very peculiar
>> situations, and I don't think it would be wise to use it as a general
>> programming habit. The problem is that it might get abused of by student=
s,
>> or people coming from the C world who still have to learn that "operator=
}"
>> can do most of the job for them. My impression is therefore that it fail=
s
>> point 2) and 3).
>
> --
>
> ---
> 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/.
--=20
Who=E2=80=99s got the sweetest disposition?
One guess, that=E2=80=99s who?
Who=E2=80=99d never, ever start an argument?
Who never shows a bit of temperament?
Who's never wrong but always right?
Who'd never dream of starting a fight?
Who get stuck with all the bad luck?
--=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/.
.
Author: =?UTF-8?Q?Germ=C3=A1n_Diago?= <germandiago@gmail.com>
Date: Thu, 23 Oct 2014 21:58:33 -0700 (PDT)
Raw View
------=_Part_1118_647720388.1414126713477
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
El mi=C3=A9rcoles, 15 de octubre de 2014 14:14:42 UTC+7, Michael Bruck escr=
ibi=C3=B3:
>
> 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.
>
>
>
I don't claim to understand your proposal completely, but one thing I think=
=20
of, if you want more control over deletions on blocks, is to just use=20
in-place construction with aligned memory or whatever in a buffer, and=20
destroy by hand.
Adding a language feature is more complexity to learn, IMHO. But I am not=
=20
sure I am covering all use cases with that.=20
--=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_1118_647720388.1414126713477
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr"><br><br>El mi=C3=A9rcoles, 15 de octubre de 2014 14:14:42 =
UTC+7, Michael Bruck escribi=C3=B3:<blockquote class=3D"gmail_quote" style=
=3D"margin: 0;margin-left: 0.8ex;border-left: 1px #ccc solid;padding-left: =
1ex;"><div dir=3D"ltr"><span><p dir=3D"ltr" style=3D"line-height:1.15;margi=
n-top:0pt;margin-bottom:0pt"><span style=3D"line-height:1.15">Hello everyon=
e,</span><br></p><p dir=3D"ltr" style=3D"line-height:1.15;margin-top:0pt;ma=
rgin-bottom:0pt"><br></p><p dir=3D"ltr" style=3D"line-height:1.15;margin-to=
p:0pt;margin-bottom:0pt"><br></p><p dir=3D"ltr" style=3D"line-height:1.15;m=
argin-top:0pt;margin-bottom:0pt">I am looking for feedback on the outline f=
or a proposal below. I would like to know if there is interest in such a fe=
ature and any ideas on improvements.</p><p dir=3D"ltr" style=3D"line-height=
:1.15;margin-top:0pt;margin-bottom:0pt"><br></p></span></div></blockquote><=
div><br></div><div>I don't claim to understand your proposal completely, bu=
t one thing I think of, if you want more control over deletions on blocks, =
is to just use </div><div>in-place construction with aligned memory or=
whatever in a buffer, and destroy by hand.</div><div><br></div><div>Adding=
a language feature is more complexity to learn, IMHO. But I am not sure I =
am covering all use cases with that. </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" 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_1118_647720388.1414126713477--
.
Author: contact@ncomputers.org
Date: Thu, 23 Oct 2014 23:01:11 -0700 (PDT)
Raw View
------=_Part_1307_1626599820.1414130471114
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
Daniel,
Thank you very much for your answer.
It is very interesting what you are suggesting.
I searched *optional.hpp* and found this code:
http://www.boost.org/doc/libs/1_56_0/boost/optional/optional.hpp
Is this which you are using?
Regards,
PF, ncomputers.org
Am Donnerstag, 23. Oktober 2014 22:30:55 UTC-5 schrieb dgutson:
>
> On Thu, Oct 23, 2014 at 3:20 PM, <con...@ncomputers.org <javascript:>>=
=20
> wrote:=20
> >> So what you are proposing is a cosmetic change (except for the special=
=20
> >> case of function arguments, which was pointed out by Roman Perepelitsa=
,=20
> but=20
> >> I doubt it is really useful).=20
> >>=20
> >> I would say the points to analyze are therefore making sure that: 1)=
=20
> you=20
> >> introduce no nasty side effects, 2) it will not make it easier for=20
> >> unexperienced programmers to make mistakes, and 3) the new syntax is=
=20
> clearer=20
> >> enough that it counter balances the increase in language complexity=20
> >> (remember that this feature will have to be taught to people at some=
=20
> points,=20
> >> think about Scott Meyer).=20
> >=20
> >=20
> > I don't think that it is only a cosmetic change.=20
> >=20
> > 2) Inexperienced programmers usually don't know what stack unwinding is=
..=20
> The=20
> > most probably is that they won't use it.=20
> >=20
> > 3) I think that it would be easier to explain "operator }" with an=20
> "operator=20
> > unwind".=20
> >=20
> > {=20
> > unsinged a;=20
> > unsigned b;=20
> > }//unwind b, unwind a;=20
> >=20
> > {=20
> > unsigned a;=20
> > throw 0;//unwind a;=20
> > unsigned b;=20
> > }//if reached, unwind b;=20
> >=20
> > {=20
> > unsigned a;=20
> > return 0;//unwind a;=20
> > unsigned b;=20
> > }//if reached, unwind b;=20
> >=20
> >=20
> > {=20
> > unsigned a;=20
> > unwind b;=20
> > unsigned a;=20
> > unwind a;=20
> > }//unwind nothing=20
>
> I don't see any need of special operator since this can be achieved=20
> with 'optional':=20
> http://pastebin.com/Qnba9gv8=20
>
>
> >=20
> > PF, ncomputers=20
> >=20
> > Am Donnerstag, 23. Oktober 2014 12:59:48 UTC-5 schrieb=20
> corentin....@cea.fr:=20
> >>=20
> >> Le mercredi 15 octobre 2014 09:14:42 UTC+2, Michael Bruck a =C3=A9crit=
:=20
> >>>=20
> >>> Hello everyone,=20
> >>>=20
> >>>=20
> >>> I am looking for feedback on the outline for a proposal below. I woul=
d=20
> >>> like to know if there is interest in such a feature and any ideas on=
=20
> >>> improvements.=20
> >>>=20
> >>>=20
> >>> Regards,=20
> >>>=20
> >>> Michael=20
> >>=20
> >>=20
> >> I am not so fond of the idea, especially because we have been heavily=
=20
> >> trained to understand and use the consequences of "operator }". This=
=20
> created=20
> >> an empirical rule, according to which (if you forbid yourself to=20
> "delete"=20
> >> pointers explicitly and respect the RAII principles) all variables are=
=20
> alive=20
> >> and valid until the end of the scope they were declared in. It would=
=20
> make=20
> >> code harder to read for me (and, I suppose, a bunch of other people).=
=20
> >> That being said, a similar situation arises with features that are=20
> >> actually part of the current C++ standard. I am thinking in particular=
=20
> about=20
> >> those people who refuse to use multiple return statements in a=20
> function. The=20
> >> argument is that it breaks the empirical rule they imposed to=20
> themselves=20
> >> that a function has only one end point. It breaks the flow of the=20
> program,=20
> >> hence they find it less readable (I am not one of those). Same thing=
=20
> with=20
> >> people that refuse to use goto, for similar reasons (I am one of=20
> those).=20
> >> It's a matter of taste really, because 1) the standard is written so=
=20
> that=20
> >> using these features has no undesirable side effects, and 2) in fact=
=20
> you can=20
> >> write optimal code without multiple return statements, and you can=20
> write=20
> >> optimal without goto. Much like you can write optimal code without you=
r=20
> >> proposal :=20
> >>=20
> >> {=20
> >> auto reply =3D []() {=20
> >> auto conn =3D []() {=20
> >> auto blob =3D []() {=20
> >> auto file =3D file_open_rlock("data_snippet");=20
> >> return file.fetch_all();=20
> >> }();=20
> >>=20
> >> auto c =3D connect_to_peer("192.128.0.1");=20
> >> c.send(blob);=20
> >> return c;=20
> >> }();=20
> >>=20
> >> return conn.fetch_reply();=20
> >> }();=20
> >>=20
> >> auto file =3D file_create("output");=20
> >> file.write(reply);=20
> >> }=20
> >>=20
> >> So what you are proposing is a cosmetic change (except for the special=
=20
> >> case of function arguments, which was pointed out by Roman Perepelitsa=
,=20
> but=20
> >> I doubt it is really useful).=20
> >>=20
> >> I would say the points to analyze are therefore making sure that: 1)=
=20
> you=20
> >> introduce no nasty side effects, 2) it will not make it easier for=20
> >> unexperienced programmers to make mistakes, and 3) the new syntax is=
=20
> clearer=20
> >> enough that it counter balances the increase in language complexity=20
> >> (remember that this feature will have to be taught to people at some=
=20
> points,=20
> >> think about Scott Meyer).=20
> >>=20
> >> Although it seems at first sight that the proposal passes point 1)=20
> above,=20
> >> it seems to me that this feature would only be used in very peculiar=
=20
> >> situations, and I don't think it would be wise to use it as a general=
=20
> >> programming habit. The problem is that it might get abused of by=20
> students,=20
> >> or people coming from the C world who still have to learn that=20
> "operator }"=20
> >> can do most of the job for them. My impression is therefore that it=20
> fails=20
> >> point 2) and 3).=20
> >=20
> > --=20
> >=20
> > ---=20
> > You received this message because you are subscribed to the Google=20
> Groups=20
> > "ISO C++ Standard - Future Proposals" group.=20
> > To unsubscribe from this group and stop receiving emails from it, send=
=20
> an=20
> > email to std-proposal...@isocpp.org <javascript:>.=20
> > To post to this group, send email to std-pr...@isocpp.org <javascript:>=
..=20
>
> > Visit this group at=20
> > http://groups.google.com/a/isocpp.org/group/std-proposals/.=20
>
>
>
> --=20
> Who=E2=80=99s got the sweetest disposition?=20
> One guess, that=E2=80=99s who?=20
> Who=E2=80=99d never, ever start an argument?=20
> Who never shows a bit of temperament?=20
> Who's never wrong but always right?=20
> Who'd never dream of starting a fight?=20
> Who get stuck with all the bad luck?=20
>
--=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_1307_1626599820.1414130471114
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">Daniel,<br><br>Thank you very much for your answer.<br><br=
>It is very interesting what you are suggesting.<br><br>I searched <b><span=
style=3D"font-family: courier new,monospace;">optional.hpp</span></b> and =
found this code:<br><br>http://www.boost.org/doc/libs/1_56_0/boost/optional=
/optional.hpp<br><br>Is this which you are using?<br><br>Regards,<br><br>PF=
, ncomputers.org<br><br>Am Donnerstag, 23. Oktober 2014 22:30:55 UTC-5 schr=
ieb dgutson:<blockquote class=3D"gmail_quote" style=3D"margin: 0;margin-lef=
t: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;">On Thu, Oct 23, 20=
14 at 3:20 PM, <<a href=3D"javascript:" target=3D"_blank" gdf-obfu=
scated-mailto=3D"ztxBOjF8Uj8J" onmousedown=3D"this.href=3D'javascript:';ret=
urn true;" onclick=3D"this.href=3D'javascript:';return true;">con...@ncompu=
ters.org</a>> wrote:
<br>>> So what you are proposing is a cosmetic change (except for the=
special
<br>>> case of function arguments, which was pointed out by Roman Per=
epelitsa, but
<br>>> I doubt it is really useful).
<br>>>
<br>>> I would say the points to analyze are therefore making sure th=
at: 1) you
<br>>> introduce no nasty side effects, 2) it will not make it easier=
for
<br>>> unexperienced programmers to make mistakes, and 3) the new syn=
tax is clearer
<br>>> enough that it counter balances the increase in language compl=
exity
<br>>> (remember that this feature will have to be taught to people a=
t some points,
<br>>> think about Scott Meyer).
<br>>
<br>>
<br>> I don't think that it is only a cosmetic change.
<br>>
<br>> 2) Inexperienced programmers usually don't know what stack unwindi=
ng is. The
<br>> most probably is that they won't use it.
<br>>
<br>> 3) I think that it would be easier to explain "operator }" with an=
"operator
<br>> unwind".
<br>>
<br>> {
<br>> unsinged a;
<br>> unsigned b;
<br>> }//unwind b, unwind a;
<br>>
<br>> {
<br>> unsigned a;
<br>> throw 0;//unwind a;
<br>> unsigned b;
<br>> }//if reached, unwind b;
<br>>
<br>> {
<br>> unsigned a;
<br>> return 0;//unwind a;
<br>> unsigned b;
<br>> }//if reached, unwind b;
<br>>
<br>>
<br>> {
<br>> unsigned a;
<br>> unwind b;
<br>> unsigned a;
<br>> unwind a;
<br>> }//unwind nothing
<br>
<br>I don't see any need of special operator since this can be achieved
<br>with 'optional':
<br><a href=3D"http://pastebin.com/Qnba9gv8" target=3D"_blank" onmousedown=
=3D"this.href=3D'http://www.google.com/url?q\75http%3A%2F%2Fpastebin.com%2F=
Qnba9gv8\46sa\75D\46sntz\0751\46usg\75AFQjCNH05U0sXJRc2HWzKsFB7ZV66SFQQQ';r=
eturn true;" onclick=3D"this.href=3D'http://www.google.com/url?q\75http%3A%=
2F%2Fpastebin.com%2FQnba9gv8\46sa\75D\46sntz\0751\46usg\75AFQjCNH05U0sXJRc2=
HWzKsFB7ZV66SFQQQ';return true;">http://pastebin.com/Qnba9gv8</a>
<br>
<br>
<br>>
<br>> PF, ncomputers
<br>>
<br>> Am Donnerstag, 23. Oktober 2014 12:59:48 UTC-5 schrieb <a>corentin=
.....@cea.fr</a>:
<br>>>
<br>>> Le mercredi 15 octobre 2014 09:14:42 UTC+2, Michael Bruck a =
=C3=A9crit :
<br>>>>
<br>>>> Hello everyone,
<br>>>>
<br>>>>
<br>>>> I am looking for feedback on the outline for a proposal be=
low. I would
<br>>>> like to know if there is interest in such a feature and an=
y ideas on
<br>>>> improvements.
<br>>>>
<br>>>>
<br>>>> Regards,
<br>>>>
<br>>>> Michael
<br>>>
<br>>>
<br>>> I am not so fond of the idea, especially because we have been =
heavily
<br>>> trained to understand and use the consequences of "operator }"=
.. This created
<br>>> an empirical rule, according to which (if you forbid yourself =
to "delete"
<br>>> pointers explicitly and respect the RAII principles) all varia=
bles are alive
<br>>> and valid until the end of the scope they were declared in. It=
would make
<br>>> code harder to read for me (and, I suppose, a bunch of other p=
eople).
<br>>> That being said, a similar situation arises with features that=
are
<br>>> actually part of the current C++ standard. I am thinking in pa=
rticular about
<br>>> those people who refuse to use multiple return statements in a=
function. The
<br>>> argument is that it breaks the empirical rule they imposed to =
themselves
<br>>> that a function has only one end point. It breaks the flow of =
the program,
<br>>> hence they find it less readable (I am not one of those). Same=
thing with
<br>>> people that refuse to use goto, for similar reasons (I am one =
of those).
<br>>> It's a matter of taste really, because 1) the standard is writ=
ten so that
<br>>> using these features has no undesirable side effects, and 2) i=
n fact you can
<br>>> write optimal code without multiple return statements, and you=
can write
<br>>> optimal without goto. Much like you can write optimal code wit=
hout your
<br>>> proposal :
<br>>>
<br>>> {
<br>>> auto reply =3D []() {
<br>>> auto conn =3D []() {
<br>>> auto blob =3D []() {
<br>>> auto f=
ile =3D file_open_rlock("data_snippet"<wbr>);
<br>>> return=
file.fetch_all();
<br>>> }();
<br>>>
<br>>> auto c =3D connect_t=
o_peer("192.128.0.1")<wbr>;
<br>>> c.send(blob);
<br>>> return c;
<br>>> }();
<br>>>
<br>>> return conn.fetch_reply();
<br>>> }();
<br>>>
<br>>> auto file =3D file_create("output");
<br>>> file.write(reply);
<br>>> }
<br>>>
<br>>> So what you are proposing is a cosmetic change (except for the=
special
<br>>> case of function arguments, which was pointed out by Roman Per=
epelitsa, but
<br>>> I doubt it is really useful).
<br>>>
<br>>> I would say the points to analyze are therefore making sure th=
at: 1) you
<br>>> introduce no nasty side effects, 2) it will not make it easier=
for
<br>>> unexperienced programmers to make mistakes, and 3) the new syn=
tax is clearer
<br>>> enough that it counter balances the increase in language compl=
exity
<br>>> (remember that this feature will have to be taught to people a=
t some points,
<br>>> think about Scott Meyer).
<br>>>
<br>>> Although it seems at first sight that the proposal passes poin=
t 1) above,
<br>>> it seems to me that this feature would only be used in very pe=
culiar
<br>>> situations, and I don't think it would be wise to use it as a =
general
<br>>> programming habit. The problem is that it might get abused of =
by students,
<br>>> or people coming from the C world who still have to learn that=
"operator }"
<br>>> can do most of the job for them. My impression is therefore th=
at it fails
<br>>> point 2) and 3).
<br>>
<br>> --
<br>>
<br>> ---
<br>> You received this message because you are subscribed to the Google=
Groups
<br>> "ISO C++ Standard - Future Proposals" group.
<br>> To unsubscribe from this group and stop receiving emails from it, =
send an
<br>> email to <a href=3D"javascript:" target=3D"_blank" gdf-obfuscated-=
mailto=3D"ztxBOjF8Uj8J" onmousedown=3D"this.href=3D'javascript:';return tru=
e;" onclick=3D"this.href=3D'javascript:';return true;">std-proposal...@<wbr=
>isocpp.org</a>.
<br>> To post to this group, send email to <a href=3D"javascript:" targe=
t=3D"_blank" gdf-obfuscated-mailto=3D"ztxBOjF8Uj8J" onmousedown=3D"this.hre=
f=3D'javascript:';return true;" onclick=3D"this.href=3D'javascript:';return=
true;">std-pr...@isocpp.org</a>.
<br>> Visit this group at
<br>> <a href=3D"http://groups.google.com/a/isocpp.org/group/std-proposa=
ls/" target=3D"_blank" onmousedown=3D"this.href=3D'http://groups.google.com=
/a/isocpp.org/group/std-proposals/';return true;" onclick=3D"this.href=3D'h=
ttp://groups.google.com/a/isocpp.org/group/std-proposals/';return true;">ht=
tp://groups.google.com/a/<wbr>isocpp.org/group/std-<wbr>proposals/</a>.
<br>
<br>
<br>
<br>--=20
<br>Who=E2=80=99s got the sweetest disposition?
<br>One guess, that=E2=80=99s who?
<br>Who=E2=80=99d never, ever start an argument?
<br>Who never shows a bit of temperament?
<br>Who's never wrong but always right?
<br>Who'd never dream of starting a fight?
<br>Who get stuck with all the bad luck?
<br></blockquote></div>
<p></p>
-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;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"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_1307_1626599820.1414130471114--
.
Author: contact@ncomputers.org
Date: Fri, 24 Oct 2014 09:14:39 -0700 (PDT)
Raw View
------=_Part_143_1479981392.1414167279847
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
Michael,
I've been thinking about this topic.
I've also a new idea:
Propose a *push* operator.
*Delete local* and also *unwind* and can be called *pop*.
It could be useful to have overloadable *push* and *pop* operators.
void operator push(){}
void operator pop(){}
void operator push(specific_arguments){}
void operator pop(specific_arguments){}
{
unsigned a;//implicit push
pop a;
unsigned a;
pop a;
push a;
a=3D0;
pop (arguments) a;
push (arguments) a;
a=3D1;
}//implicit pop
This could be useful to make distinctions for objcts created with the new=
=20
operator and objects created in a fixed way.
PF, ncomputers.org
Am Donnerstag, 23. Oktober 2014 11:58:24 UTC-5 schrieb=20
con...@ncomputers.org:
>
> Michael,
>
> I've read your proposal. I think that it is a good one and that it is eve=
n=20
> necessary to be implemented one day.
>
> I want to share with you my points of view with the intention to help you=
=20
> improve it.
>
> So far I know this is very strong related with stack unwinding. Stack=20
> works with LIFO (Last input, last output). The objects are deleted in the=
=20
> inverse order they were created. For example:
>
> #include<iostream>
> using namespace std;
>
> struct A{
> unsigned a;
> A(unsigned aa):a(aa){};
> ~A(){
> cout<<"deleting "<<a<<endl;
> }
> };
>
> int main(){
> A a(0),b(1),c(2);
> }//delete local c,b,a;
>
> What you are proposing is to allow the handling of the stack. Deleted=20
> variables should be pushed out from the stack. You called "}" as operator=
..
>
> I would call it unwind operator
>
> delete local would be an operator composed by two words. Instead of delet=
e=20
> local, it could be more accurate: unwind operator.
>
> This operator should be able to be overloaded with and without specific=
=20
> arguments.
>
> void operator unwind(){}
> void operator unwind(int a,int b){}
>
> int main(){
> string a;
> unwind a;
> string b;
> unwind(0,1)b;
> }
>
> (Every time that the stack unwinds implicitly a variable or object, the=
=20
> operator without specific arguments would be called if present).
>
> For example:
>
> {
> string a;
> }//implicit call to string::operator unwind() if present
>
> I think that even with conditional unwindings the code should be compiled=
,=20
> only that the operator should behave different.
>
> For example (without conditional unwindings):
>
> i
> nt main(){
> string a;//use 0x01
> unwind a;//free 0x01
> string b;//use 0x01
> unwind b;//free 0x01
> string c;//use 0x01
> }//implicit unwind c and free 0x01
>
> With conditional unwindings:
>
> int main(){
> string a;//use 0x01
> if(condition)unwind a;//destroy the object, call the unwind operator=
=20
> if present and remove 'a' from stack
> string b;//use 0x02
> b=3Da;//To read an unwinded variable should cause undefined behaviour
> unwind b;//free 0x02
> string c;//use 0x02
> }//unwind c and free 0x02
>
> It is important to also consider the* return* and *throw* keywords in=20
> your proposal.
>
> int main(){
> string a;
> string b;
> string c;
> unwind a;
> throw 0;//implicit unwind of c and b
> return 0;//implicit unwind of c and b
> }
>
> You wrote:
>
> delete local file, reply;
>
>
> I think that this would also be a good syntax for the *delete* and=20
> *delete[]* operators:
>
> delete[]a,b,c,d;
>
> But this is not possible because the comma operator has other purpose, fo=
r=20
> example:
>
> delete[]a=3Da-1,a,
> delete[]b=3Db+5,b,
> delete[]c=3Dc*3,c,
> delete[]--d,d;
>
> The comma operator has the purpose to help the value to be calculated and=
=20
> it will always be considered only the most right expression:
>
> delete[]a,b,c,d;
>
> Only deletes d;
>
> So I think that instead of:
>
> delete local file,replay;
>
> It should be:
>
> delete local file,delete local replay;
>
> Or:
>
> unwind file,unwind replay;
>
> I didn't understand this very well:
>
> 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.
>
>
> Can you write me please an example?=20
>
> Regards,
>
> PF, ncomputers
>
> Am Mittwoch, 15. Oktober 2014 02:14:42 UTC-5 schrieb Michael Bruck:
>
> 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-def=
ined 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 sometimes=
=20
> overlap in complex ways.
>
> Sometimes objects hold expensive resources and especially with programmin=
g=20
> patterns like threading or resumable functions the resources can remain=
=20
> blocked long after use if other functions in the same block require a lon=
g=20
> 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");
>
> au
>
> ...
--=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_143_1479981392.1414167279847
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">Michael,<br><br>I've been thinking about this topic.<br><b=
r>I've also a new idea:<br><br>Propose a <b><span style=3D"font-family: cou=
rier new,monospace;">push</span></b> operator.<br><br><span style=3D"font-f=
amily: courier new,monospace;"><b>Delete local</b></span> and also <b><span=
style=3D"font-family: courier new,monospace;">unwind</span></b> and can be=
called <b><span style=3D"font-family: courier new,monospace;">pop</span></=
b>.<br><br>It could be useful to have overloadable <span style=3D"font-fami=
ly: courier new,monospace;"><b>push</b></span> and <span style=3D"font-fami=
ly: courier new,monospace;"><b>pop</b></span> operators.<br><br><div class=
=3D"prettyprint" style=3D"background-color: rgb(250, 250, 250); border-colo=
r: rgb(187, 187, 187); border-style: solid; border-width: 1px; word-wrap: b=
reak-word;"><code class=3D"prettyprint"><div class=3D"subprettyprint"><span=
style=3D"color: #008;" class=3D"styled-by-prettify">void</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: =
#000;" class=3D"styled-by-prettify"> push</span><span style=3D"color: #660;=
" class=3D"styled-by-prettify">(){}</span><span style=3D"color: #000;" clas=
s=3D"styled-by-prettify"><br></span><span style=3D"color: #008;" class=3D"s=
tyled-by-prettify">void</span><span style=3D"color: #000;" class=3D"styled-=
by-prettify"> </span><span style=3D"color: #008;" class=3D"styled-by-pretti=
fy">operator</span><span style=3D"color: #000;" class=3D"styled-by-prettify=
"> pop</span><span style=3D"color: #660;" class=3D"styled-by-prettify">(){}=
</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br><br></=
span><span style=3D"color: #008;" class=3D"styled-by-prettify">void</span><=
span style=3D"color: #000;" class=3D"styled-by-prettify"> </span><span styl=
e=3D"color: #008;" class=3D"styled-by-prettify">operator</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"> push</span><span style=3D"c=
olor: #660;" class=3D"styled-by-prettify">(</span><span style=3D"color: #00=
0;" class=3D"styled-by-prettify">specific_arguments</span><span style=3D"co=
lor: #660;" class=3D"styled-by-prettify">){}</span><span style=3D"color: #0=
00;" class=3D"styled-by-prettify"><br></span><span style=3D"color: #008;" c=
lass=3D"styled-by-prettify">void</span><span style=3D"color: #000;" class=
=3D"styled-by-prettify"> </span><span style=3D"color: #008;" class=3D"style=
d-by-prettify">operator</span><span style=3D"color: #000;" class=3D"styled-=
by-prettify"> pop</span><span style=3D"color: #660;" class=3D"styled-by-pre=
ttify">(</span><span style=3D"color: #000;" class=3D"styled-by-prettify">sp=
ecific_arguments</span><span style=3D"color: #660;" class=3D"styled-by-pret=
tify">){}</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><=
br><br></span><span style=3D"color: #660;" class=3D"styled-by-prettify">{</=
span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br> &=
nbsp; </span><span style=3D"color: #008;" class=3D"styled-by-prettify=
">unsigned</span><span style=3D"color: #000;" class=3D"styled-by-prettify">=
a</span><span style=3D"color: #660;" class=3D"styled-by-prettify">;</span>=
<span style=3D"color: #800;" class=3D"styled-by-prettify">//implicit push</=
span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br> &=
nbsp; pop a</span><span style=3D"color: #660;" class=3D"styled-by-pre=
ttify">;</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><b=
r> </span><span style=3D"color: #008;" class=3D"styled-b=
y-prettify">unsigned</span><span style=3D"color: #000;" class=3D"styled-by-=
prettify"> a</span><span style=3D"color: #660;" class=3D"styled-by-prettify=
">;</span><span style=3D"color: #000;" class=3D"styled-by-prettify"></span>=
<br> pop a;<br><span style=3D"color: #000;" class=
=3D"styled-by-prettify"><code class=3D"prettyprint"><span style=3D"color: #=
000;" class=3D"styled-by-prettify"> push a</span><span s=
tyle=3D"color: #660;" class=3D"styled-by-prettify">;</span><span style=3D"c=
olor: #000;" class=3D"styled-by-prettify"></span></code></span><span style=
=3D"color: #000;" class=3D"styled-by-prettify"><br> a</s=
pan><span style=3D"color: #660;" class=3D"styled-by-prettify">=3D</span><sp=
an style=3D"color: #066;" class=3D"styled-by-prettify">0</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">;</span><span style=3D"color=
: #000;" class=3D"styled-by-prettify"><br> pop </span><s=
pan style=3D"color: #660;" class=3D"styled-by-prettify">(</span><span style=
=3D"color: #000;" class=3D"styled-by-prettify">arguments</span><span style=
=3D"color: #660;" class=3D"styled-by-prettify">)</span><span style=3D"color=
: #000;" class=3D"styled-by-prettify"> a</span><span style=3D"color: #660;"=
class=3D"styled-by-prettify">;</span><span style=3D"color: #000;" class=3D=
"styled-by-prettify"><br> push </span><span style=3D"col=
or: #660;" class=3D"styled-by-prettify">(</span><span style=3D"color: #000;=
" class=3D"styled-by-prettify">arguments</span><span style=3D"color: #660;"=
class=3D"styled-by-prettify">)</span><span style=3D"color: #000;" class=3D=
"styled-by-prettify"> a</span><span style=3D"color: #660;" class=3D"styled-=
by-prettify">;</span><span style=3D"color: #000;" class=3D"styled-by-pretti=
fy"><br> a</span><span style=3D"color: #660;" class=3D"s=
tyled-by-prettify">=3D</span><span style=3D"color: #066;" class=3D"styled-b=
y-prettify">1</span><span style=3D"color: #660;" class=3D"styled-by-prettif=
y">;</span><span style=3D"color: #000;" class=3D"styled-by-prettify"><br></=
span><span style=3D"color: #660;" class=3D"styled-by-prettify">}</span><spa=
n style=3D"color: #800;" class=3D"styled-by-prettify">//implicit pop</span>=
<span style=3D"color: #000;" class=3D"styled-by-prettify"><br></span></div>=
</code></div><br>This could be useful to make distinctions for objcts creat=
ed with the new operator and objects created in a fixed way.<br><br>PF, nco=
mputers.org<br><br>Am Donnerstag, 23. Oktober 2014 11:58:24 UTC-5 schrieb c=
on...@ncomputers.org:<blockquote class=3D"gmail_quote" style=3D"margin: 0;m=
argin-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><div dir=
=3D"ltr">Michael,<br><br>I've read your proposal. I think that it is a good=
one and that it is even necessary to be implemented one day.<br><br>I want=
to share with you my points of view with the intention to help you improve=
it.<br><br>So far I know this is very strong related with stack unwinding.=
Stack works with LIFO (Last input, last output). The objects are deleted i=
n the inverse order they were created. For example:<br><br><div style=3D"ba=
ckground-color:rgb(250,250,250);border-color:rgb(187,187,187);border-style:=
solid;border-width:1px;word-wrap:break-word"><code><div><span style=3D"colo=
r:#800">#include</span><span style=3D"color:#080"><iostream></span><s=
pan style=3D"color:#000"><br></span><span style=3D"color:#008">using</span>=
<span style=3D"color:#000"> </span><span style=3D"color:#008">namespace</sp=
an><span style=3D"color:#000"> std</span><span style=3D"color:#660">;</span=
><span style=3D"color:#000"><br><br></span><span style=3D"color:#008">struc=
t</span><span style=3D"color:#000"> A</span><span style=3D"color:#660">{</s=
pan><span style=3D"color:#000"><br> </span><span style=3D"colo=
r:#008">unsigned</span><span style=3D"color:#000"> a</span><span style=3D"c=
olor:#660">;</span><span style=3D"color:#000"><br> A</span><sp=
an style=3D"color:#660">(</span><span style=3D"color:#008">unsigned</span><=
span style=3D"color:#000"> aa</span><span style=3D"color:#660">):</span><sp=
an style=3D"color:#000">a</span><span style=3D"color:#660">(</span><span st=
yle=3D"color:#000">aa</span><span style=3D"color:#660">){};</span><span sty=
le=3D"color:#000"><br> </span><span style=3D"color:#660">~</sp=
an><span style=3D"color:#000">A</span><span style=3D"color:#660">(){</span>=
<span style=3D"color:#000"><br> cout</span><span=
style=3D"color:#660"><<</span><span style=3D"color:#080">"deleting "=
</span><span style=3D"color:#660"><<</span><span style=3D"color:#000"=
>a</span><span style=3D"color:#660"><<</span><span style=3D"color:#00=
0">endl</span><span style=3D"color:#660">;</span><span style=3D"color:#000"=
><br> </span><span style=3D"color:#660">}</span><span style=3D=
"color:#000"><br></span><span style=3D"color:#660">};</span><span style=3D"=
color:#000"><br><br></span><span style=3D"color:#008">int</span><span style=
=3D"color:#000"> main</span><span style=3D"color:#660">(){</span><span styl=
e=3D"color:#000"><br> A a</span><span style=3D"color:#660">(</=
span><span style=3D"color:#066">0</span><span style=3D"color:#660">),</span=
><span style=3D"color:#000">b</span><span style=3D"color:#660">(</span><spa=
n style=3D"color:#066">1</span><span style=3D"color:#660">),</span><span st=
yle=3D"color:#000">c</span><span style=3D"color:#660">(</span><span style=
=3D"color:#066">2</span><span style=3D"color:#660">);</span><span style=3D"=
color:#000"><br></span><span style=3D"color:#660">}</span><span style=3D"co=
lor:#800">//delete local c,b,a;</span><span style=3D"color:#000"><br></span=
></div></code></div><br>What you are proposing is to allow the handling of =
the stack. Deleted variables should be pushed out from the stack. You calle=
d "}" as operator.<br><br>I would call it <span style=3D"background-color:r=
gb(238,238,238)"><span style=3D"font-family:courier new,monospace">unwind o=
perator</span></span><br><br><span style=3D"background-color:rgb(238,238,23=
8)"><span style=3D"font-family:courier new,monospace">delete local</span></=
span> would be an operator composed by two words. Instead of <span style=3D=
"font-family:courier new,monospace"><span style=3D"background-color:rgb(238=
,238,238)">delete local</span></span>, it could be more accurate: <span sty=
le=3D"background-color:rgb(238,238,238)"><span style=3D"font-family:courier=
new,monospace">unwind operator</span></span>.<br><br>This operator should =
be able to be overloaded with and without specific arguments.<br><br><div s=
tyle=3D"background-color:rgb(250,250,250);border-color:rgb(187,187,187);bor=
der-style:solid;border-width:1px;word-wrap:break-word"><code><div><span sty=
le=3D"color:#008">void</span><span style=3D"color:#000"> </span><span style=
=3D"color:#008">operator</span><span style=3D"color:#000"> unwind</span><sp=
an style=3D"color:#660">(){}</span><span style=3D"color:#000"><br></span><s=
pan style=3D"color:#008">void</span><span style=3D"color:#000"> </span><spa=
n style=3D"color:#008">operator</span><span style=3D"color:#000"> unwind</s=
pan><span style=3D"color:#660">(</span><span style=3D"color:#008">int</span=
><span style=3D"color:#000"> a</span><span style=3D"color:#660">,</span><sp=
an style=3D"color:#008">int</span><span style=3D"color:#000"> b</span><span=
style=3D"color:#660">){}</span><span style=3D"color:#000"><br><br></span><=
span style=3D"color:#008">int</span><span style=3D"color:#000"> main</span>=
<span style=3D"color:#660">(){</span><span style=3D"color:#000"><br> =
</span><span style=3D"color:#008">string</span><span style=3D"color:=
#000"> a</span><span style=3D"color:#660">;</span><span style=3D"color:#000=
"><br> unwind a</span><span style=3D"color:#660">;</span><span=
style=3D"color:#000"><br> </span><span style=3D"color:#008">s=
tring</span><span style=3D"color:#000"> b</span><span style=3D"color:#660">=
;</span><span style=3D"color:#000"><br> unwind</span><span sty=
le=3D"color:#660">(</span><span style=3D"color:#066">0</span><span style=3D=
"color:#660">,</span><span style=3D"color:#066">1</span><span style=3D"colo=
r:#660">)</span><span style=3D"color:#000">b</span><span style=3D"color:#66=
0">;</span><span style=3D"color:#000"><br></span><span style=3D"color:#660"=
>}</span><span style=3D"color:#000"><br></span></div></code></div><br>(Ever=
y time that the stack unwinds implicitly a variable or object, the operator=
without specific arguments would be called if present).<br><br>For example=
:<br><br><div style=3D"background-color:rgb(250,250,250);border-color:rgb(1=
87,187,187);border-style:solid;border-width:1px;word-wrap:break-word"><code=
><div><span style=3D"color:#660">{</span><span style=3D"color:#000"><br>&nb=
sp; </span><span style=3D"color:#008">string</span><span style=3D"co=
lor:#000"> a</span><span style=3D"color:#660">;</span><span style=3D"color:=
#000"><br></span><span style=3D"color:#660">}</span><span style=3D"color:#8=
00">//implicit call to string::operator unwind() if present</span><span sty=
le=3D"color:#000"><br></span></div></code></div><br>I think that even with =
conditional unwindings the code should be compiled, only that the operator =
should behave different.<br><br>For example (without conditional unwindings=
):<br><br>i<div style=3D"background-color:rgb(250,250,250);border-color:rgb=
(187,187,187);border-style:solid;border-width:1px;word-wrap:break-word"><co=
de><div><span style=3D"color:#000">nt main</span><span style=3D"color:#660"=
>(){</span><span style=3D"color:#000"><br> </span><span style=
=3D"color:#008">string</span><span style=3D"color:#000"> a</span><span styl=
e=3D"color:#660">;</span><span style=3D"color:#800">//use 0x01</span>=
<span style=3D"color:#000"><br> unwind a</span><span style=3D"=
color:#660">;</span><span style=3D"color:#800">//free 0x01</span><span styl=
e=3D"color:#000"><br> </span><span style=3D"color:#008">string=
</span><span style=3D"color:#000"> b</span><span style=3D"color:#660">;</sp=
an><span style=3D"color:#800">//use 0x01</span><span style=3D"color:#=
000"><br> unwind b</span><span style=3D"color:#660">;</span><s=
pan style=3D"color:#800">//free 0x01</span><span style=3D"color:#000"><br>&=
nbsp; </span><span style=3D"color:#008">string</span><span style=3D"=
color:#000"> c</span><span style=3D"color:#660">;</span><span style=3D"colo=
r:#800">//use 0x01</span><span style=3D"color:#000"><br></span><span =
style=3D"color:#660">}</span><span style=3D"color:#800">//implicit unwind c=
and free 0x01</span><span style=3D"color:#000"><br></span></div></code></d=
iv><br>With conditional unwindings:<br><br><div style=3D"background-color:r=
gb(250,250,250);border-color:rgb(187,187,187);border-style:solid;border-wid=
th:1px;word-wrap:break-word"><code><div><span style=3D"color:#008">int</spa=
n><span style=3D"color:#000"> main</span><span style=3D"color:#660">(){</sp=
an><span style=3D"color:#000"><br> </span><span style=3D"color=
:#008">string</span><span style=3D"color:#000"> a</span><span style=3D"colo=
r:#660">;</span><span style=3D"color:#800">//use 0x01</span><span sty=
le=3D"color:#000"><br> </span><span style=3D"color:#008">if</s=
pan><span style=3D"color:#660">(</span><span style=3D"color:#000">condition=
</span><span style=3D"color:#660">)</span><span style=3D"color:#000">unwind=
a</span><span style=3D"color:#660">;</span><span style=3D"color:#800">//de=
stroy the object, call the unwind operator if present and remove 'a' from s=
tack</span><span style=3D"color:#000"><br> </span><span style=
=3D"color:#008">string</span><span style=3D"color:#000"> b</span><span styl=
e=3D"color:#660">;</span><span style=3D"color:#800">//use 0x02</span>=
<span style=3D"color:#000"><br> b</span><span style=3D"color:#=
660">=3D</span><span style=3D"color:#000">a</span><span style=3D"color:#660=
">;</span><span style=3D"color:#800">//To read an unwinded variable should =
cause undefined behaviour</span><span style=3D"color:#000"><br>  =
; unwind b</span><span style=3D"color:#660">;</span><span style=3D"color:#8=
00">//free 0x02</span><span style=3D"color:#000"><br> </span><=
span style=3D"color:#008">string</span><span style=3D"color:#000"> c</span>=
<span style=3D"color:#660">;</span><span style=3D"color:#800">//use 0=
x02</span><span style=3D"color:#000"><br></span><span style=3D"color:#660">=
}</span><span style=3D"color:#800">//unwind c and free 0x02</span><span sty=
le=3D"color:#000"><br></span></div></code></div><br>It is important to also=
consider the<b><span style=3D"font-family:courier new,monospace"> <span st=
yle=3D"background-color:rgb(238,238,238)">return</span></span></b> and <spa=
n style=3D"background-color:rgb(238,238,238)"><span style=3D"font-family:co=
urier new,monospace"><b>throw</b></span></span> keywords in your proposal.<=
br><br><div 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><=
div><span style=3D"color:#008">int</span><span style=3D"color:#000"> main</=
span><span style=3D"color:#660">(){</span><span style=3D"color:#000"><br>&n=
bsp; </span><span style=3D"color:#008">string</span><span style=3D"c=
olor:#000"> a</span><span style=3D"color:#660">;</span><span style=3D"color=
:#000"><br> </span><span style=3D"color:#008">string</span><sp=
an style=3D"color:#000"> b</span><span style=3D"color:#660">;</span><span s=
tyle=3D"color:#000"><br> </span><span style=3D"color:#008">str=
ing</span><span style=3D"color:#000"> c</span><span style=3D"color:#660">;<=
/span><span style=3D"color:#000"><br> unwind a</span><span sty=
le=3D"color:#660">;</span><span style=3D"color:#000"><br> </sp=
an><span style=3D"color:#008">throw</span><span style=3D"color:#000"> </spa=
n><span style=3D"color:#066">0</span><span style=3D"color:#660">;</span><sp=
an style=3D"color:#800">//implicit unwind of c and b</span><span style=3D"c=
olor:#000"><br> </span><span style=3D"color:#008">return</span=
><span style=3D"color:#000"> </span><span style=3D"color:#066">0</span><spa=
n style=3D"color:#660">;</span><span style=3D"color:#800">//implicit unwind=
of c and b</span><span style=3D"color:#000"><br></span><span style=3D"colo=
r:#660">}</span><span style=3D"color:#000"><br></span></div></code></div><b=
r>You wrote:<br><br><blockquote style=3D"margin:0px 0px 0px 0.8ex;border-le=
ft:1px solid rgb(204,204,204);padding-left:1ex"><span><span style=3D"font-s=
ize:15px;font-family:'Courier New';color:rgb(0,0,0);font-weight:bold;white-=
space:pre-wrap;background-color:transparent">delete local file, reply;</spa=
n></span><br></blockquote><br>I think that this would also be a good syntax=
for the <span style=3D"font-family:courier new,monospace"><span style=3D"b=
ackground-color:rgb(238,238,238)"><b>delete</b></span></span> and <span sty=
le=3D"font-family:courier new,monospace"><span style=3D"background-color:rg=
b(238,238,238)"><b>delete[]</b></span></span> operators:<br><br><div 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><div><span style=
=3D"color:#008">delete</span><span style=3D"color:#660">[]</span><span styl=
e=3D"color:#000">a</span><span style=3D"color:#660">,</span><span style=3D"=
color:#000">b</span><span style=3D"color:#660">,</span><span style=3D"color=
:#000">c</span><span style=3D"color:#660">,</span><span style=3D"color:#000=
">d</span><span style=3D"color:#660">;</span><span style=3D"color:#000"><br=
></span></div></code></div><br>But this is not possible because the comma o=
perator has other purpose, for example:<br><br><div style=3D"background-col=
or:rgb(250,250,250);border-color:rgb(187,187,187);border-style:solid;border=
-width:1px;word-wrap:break-word"><code><div><span style=3D"color:#008">dele=
te</span><span style=3D"color:#660">[]</span><span style=3D"color:#000">a</=
span><span style=3D"color:#660">=3D</span><span style=3D"color:#000">a</spa=
n><span style=3D"color:#660">-</span><span style=3D"color:#066">1</span><sp=
an style=3D"color:#660">,</span><span style=3D"color:#000">a</span><span st=
yle=3D"color:#660">,</span><span style=3D"color:#000"><br></span><span styl=
e=3D"color:#008">delete</span><span style=3D"color:#660">[]</span><span sty=
le=3D"color:#000">b</span><span style=3D"color:#660">=3D</span><span style=
=3D"color:#000">b</span><span style=3D"color:#660">+</span><span style=3D"c=
olor:#066">5</span><span style=3D"color:#660">,</span><span style=3D"color:=
#000">b</span><span style=3D"color:#660">,</span><span style=3D"color:#000"=
><br></span><span style=3D"color:#008">delete</span><span style=3D"color:#6=
60">[]</span><span style=3D"color:#000">c</span><span style=3D"color:#660">=
=3D</span><span style=3D"color:#000">c</span><span style=3D"color:#660">*</=
span><span style=3D"color:#066">3</span><span style=3D"color:#660">,</span>=
<span style=3D"color:#000">c</span><span style=3D"color:#660">,</span><span=
style=3D"color:#000"><br></span><span style=3D"color:#008">delete</span><s=
pan style=3D"color:#660">[]--</span><span style=3D"color:#000">d</span><spa=
n style=3D"color:#660">,</span><span style=3D"color:#000">d</span><span sty=
le=3D"color:#660">;</span><span style=3D"color:#000"><br></span></div></cod=
e></div><br>The comma operator has the purpose to help the value to be calc=
ulated and it will always be considered only the most right expression:<br>=
<br><div style=3D"background-color:rgb(250,250,250);border-color:rgb(187,18=
7,187);border-style:solid;border-width:1px;word-wrap:break-word"><code><div=
><span style=3D"color:#008">delete</span><span style=3D"color:#660">[]</spa=
n><span style=3D"color:#000">a</span><span style=3D"color:#660">,</span><sp=
an style=3D"color:#000">b</span><span style=3D"color:#660">,</span><span st=
yle=3D"color:#000">c</span><span style=3D"color:#660">,</span><span style=
=3D"color:#000">d</span><span style=3D"color:#660">;</span><span style=3D"c=
olor:#000"><br></span></div></code></div><br>Only deletes d;<br><br>So I th=
ink that instead of:<br><br><div style=3D"background-color:rgb(250,250,250)=
;border-color:rgb(187,187,187);border-style:solid;border-width:1px;word-wra=
p:break-word"><code><div><span style=3D"color:#008">delete</span><span styl=
e=3D"color:#000"> </span><span style=3D"color:#008">local</span><span style=
=3D"color:#000"> file</span><span style=3D"color:#660">,</span><span style=
=3D"color:#000">replay</span><span style=3D"color:#660">;</span><span style=
=3D"color:#000"><br></span></div></code></div><br>It should be:<br><br><div=
style=3D"background-color:rgb(250,250,250);border-color:rgb(187,187,187);b=
order-style:solid;border-width:1px;word-wrap:break-word"><code><div><span s=
tyle=3D"color:#008">delete</span><span style=3D"color:#000"> </span><span s=
tyle=3D"color:#008">local</span><span style=3D"color:#000"> file</span><spa=
n style=3D"color:#660">,</span><span style=3D"color:#008">delete</span><spa=
n style=3D"color:#000"> </span><span style=3D"color:#008">local</span><span=
style=3D"color:#000"> replay</span><span style=3D"color:#660">;</span><spa=
n style=3D"color:#000"><br></span></div></code></div><br>Or:<br><br><div st=
yle=3D"background-color:rgb(250,250,250);border-color:rgb(187,187,187);bord=
er-style:solid;border-width:1px;word-wrap:break-word"><code><div><span styl=
e=3D"color:#000">unwind file</span><span style=3D"color:#660">,</span><span=
style=3D"color:#000">unwind replay</span><span style=3D"color:#660">;</spa=
n><span style=3D"color:#000"><br></span></div></code></div><br>I didn't und=
erstand this very well:<br><br><blockquote style=3D"margin:0px 0px 0px 0.8e=
x;border-left:1px solid rgb(204,204,204);padding-left:1ex"><span><p dir=3D"=
ltr" style=3D"line-height:1.15;margin-top:0pt;margin-bottom:0pt"><span styl=
e=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:15px;fo=
nt-family:'Courier New';color:rgb(0,0,0);white-space:pre-wrap;background-co=
lor:transparent">goto</span><span style=3D"font-size:15px;font-family:Arial=
;color:rgb(0,0,0);white-space:pre-wrap;background-color:transparent"> cross=
es </span><span style=3D"font-size:15px;font-family:'Courier New';color:rgb=
(0,0,0);white-space:pre-wrap;background-color:transparent">delete local</sp=
an><span style=3D"font-size:15px;font-family:Arial;color:rgb(0,0,0);white-s=
pace:pre-wrap;background-color:transparent"> in the direction of the progra=
m 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:'Couri=
er New';color:rgb(0,0,0);white-space:pre-wrap;background-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"> passes </span><span s=
tyle=3D"font-size:15px;font-family:'Courier New';color:rgb(0,0,0);white-spa=
ce: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;bac=
kground-color:transparent"> it must also pass the point of declaration of t=
he name.</span></p></span></blockquote><div><br>Can you write me please an =
example? <br></div><br>Regards,<br><br>PF, ncomputers<br><br>Am Mittwoch, 1=
5. Oktober 2014 02:14:42 UTC-5 schrieb Michael Bruck:<blockquote style=3D"m=
argin:0;margin-left:0.8ex;border-left:1px #ccc solid;padding-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">Hello everyone,</span><=
br></p><p dir=3D"ltr" style=3D"line-height:1.15;margin-top:0pt;margin-botto=
m:0pt"><br></p><p dir=3D"ltr" style=3D"line-height:1.15;margin-top:0pt;marg=
in-bottom:0pt"><br></p><p dir=3D"ltr" style=3D"line-height:1.15;margin-top:=
0pt;margin-bottom:0pt">I am looking for feedback on the outline for a propo=
sal 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"line-height:1.15;marg=
in-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"><br></p><p dir=3D"ltr" style=
=3D"line-height:1.15;margin-top:0pt;margin-bottom:0pt">Regards,</p><p dir=
=3D"ltr" style=3D"line-height:1.15;margin-top:0pt;margin-bottom:0pt">Michae=
l</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"><span style=3D"font-size:28px;font-family:'Trebuchet MS';color=
:rgb(0,0,0);white-space:pre-wrap;background-color:transparent"><br></span><=
/p><p dir=3D"ltr" style=3D"line-height:1.15;margin-top:0pt;margin-bottom:0p=
t"><span style=3D"font-family:'Trebuchet MS';color:rgb(0,0,0);white-space:p=
re-wrap;background-color:transparent"><font size=3D"4">Deleting local varia=
bles</font></span></p><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;background-color:transparent"><font size=3D"4"=
>Summary</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">This pr=
oposal introduces a way to end the scope of a variable before its enclosing=
block ends.</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">std::string foo, bar;</span></p><p dir=3D"ltr" style=3D"line-height:1.1=
5;margin-top:0pt;margin-bottom:0pt;text-indent:36pt"><span style=3D"font-si=
ze:15px;font-family:'Courier New';color:rgb(0,0,0);white-space:pre-wrap;bac=
kground-color:transparent">...</span></p><p dir=3D"ltr" style=3D"line-heigh=
t:1.15;margin-top:0pt;margin-bottom:0pt;text-indent:36pt"><span style=3D"fo=
nt-size:15px;font-family:'Courier New';color:rgb(0,0,0);font-weight:bold;wh=
ite-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:p=
re-wrap;background-color:transparent"> </span><span style=3D"font-size:15px=
;font-family:'Courier New';color:rgb(0,0,0);font-weight:bold;white-space:pr=
e-wrap;background-color:transparent">local</span><span style=3D"font-size:1=
5px;font-family:'Courier New';color:rgb(0,0,0);white-space:pre-wrap;backgro=
und-color:transparent"> foo, bar;</span></p><p dir=3D"ltr" style=3D"line-he=
ight: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-color:transparent">...</span></p><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:'Courier New';color:rgb(0,0,0);white-space:pre-wrap;backgro=
und-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:'Trebuc=
het MS';color:rgb(0,0,0);white-space:pre-wrap;background-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:15p=
x;font-family:Arial;color:rgb(0,0,0);white-space:pre-wrap;background-color:=
transparent">The =E2=80=9C} operator=E2=80=9D is powerful but but comes wit=
h a pre-defined destruction order which is not suitable for all application=
s. In real world programs the desired scopes of objects are not always clea=
nly nested but sometimes overlap in complex ways.</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:Arial;color:rgb(0,0,0);white-space:pre-wrap;back=
ground-color:transparent">Sometimes objects hold expensive resources and es=
pecially with programming patterns like threading or resumable functions th=
e resources can remain blocked long after use if other functions in the sam=
e block require a long time to complete.</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:Arial;color:rgb(0,0,0);white-space:pre-wrap;backgroun=
d-color:transparent">This leads to programming patterns that try to mitigat=
e 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:'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-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 file =3D file=
_open_rlock("data_snippet"<wbr>);</span></p><p dir=3D"ltr" style=3D"line-he=
ight: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-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-color:transparent">file.cl=
ose();</span></p><br><p dir=3D"ltr" style=3D"line-height:1.15;margin-top:0p=
t;margin-bottom:0pt;text-indent:36pt"><span style=3D"font-size:15px;font-fa=
mily:'Courier New';color:rgb(0,0,0);white-space:pre-wrap;background-color:t=
ransparent">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;tex=
t-indent:36pt"><span style=3D"font-size:15px;font-family:'Courier New';colo=
r:rgb(0,0,0);white-space:pre-wrap;background-color:transparent">conn.send(b=
lob);</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">blob.destroy();</span></p><p dir=3D"ltr" style=3D"line-height:1.15;m=
argin-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;backgr=
ound-color:transparent">auto reply =3D conn.fetch_reply();</span></p><p dir=
=3D"ltr" style=3D"line-height:1.15;margin-top:0pt;margin-bottom:0pt;text-in=
dent:36pt"><span style=3D"font-size:15px;font-family:'Courier New';color:rg=
b(0,0,0);white-space:pre-wrap;background-color:transparent">conn.disconnect=
();</span></p><br><p dir=3D"ltr" style=3D"line-height:1.15;margin-top:0pt;m=
argin-bottom:0pt;text-indent:36pt"><span style=3D"font-size:15px;font-famil=
y:'Courier New';color:rgb(0,0,0);white-space:pre-wrap;background-color:tran=
sparent">auto file2 =3D file_create("output");</span></p><p dir=3D"ltr" sty=
le=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);whi=
te-space:pre-wrap;background-color:transparent">file2.write(reply);</span><=
/p><p dir=3D"ltr" style=3D"line-height:1.15;margin-top:0pt;margin-bottom:0p=
t;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">reply.=
destroy();</span></p><p dir=3D"ltr" style=3D"line-height:1.15;margin-top:0p=
t;margin-bottom:0pt;text-indent:36pt"><span style=3D"font-size:15px;font-fa=
mily:'Courier New';color:rgb(0,0,0);white-space:pre-wrap;background-color:t=
ransparent">file2.close();</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-fam=
ily:'Courier New';color:rgb(0,0,0);white-space:pre-wrap;background-color:tr=
ansparent">}</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:Arial;=
color:rgb(0,0,0);white-space:pre-wrap;background-color:transparent">There a=
re a number of problems with this solution:</span></p><ul style=3D"margin-t=
op:0pt;margin-bottom:0pt"><li dir=3D"ltr" style=3D"list-style-type:disc;fon=
t-size:15px;font-family:Arial;color:rgb(0,0,0);vertical-align:baseline;back=
ground-color:transparent"><p dir=3D"ltr" style=3D"line-height:1.15;margin-t=
op:0pt;margin-bottom:0pt"><span style=3D"font-size:15px;white-space:pre-wra=
p;background-color:transparent">The library needs to provide a function tha=
t releases expensive resources in addition to the destructor.</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 library needs to keep track of the additional state in which re=
sources 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;col=
or: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:transparent">=
The user needs to locate such a function and understand its semantics to se=
e if it really releases enough resources.</span></p></li><li dir=3D"ltr" st=
yle=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" sty=
le=3D"line-height:1.15;margin-top:0pt;margin-bottom:0pt"><span style=3D"fon=
t-size:15px;white-space:pre-wrap;background-color:transparent">The neutered=
object still lingers in some form on the stack until the end of the scope.=
</span></p></li><li dir=3D"ltr" style=3D"list-style-type:disc;font-size:15p=
x;font-family:Arial;color:rgb(0,0,0);vertical-align:baseline;background-col=
or:transparent"><p dir=3D"ltr" style=3D"line-height:1.15;margin-top:0pt;mar=
gin-bottom:0pt"><span style=3D"font-size:15px;white-space:pre-wrap;backgrou=
nd-color:transparent">The compiler can not diagnose at compile time when su=
ch an already neutered object is used accidentally due to code rewrite etc.=
</span></p></li><li dir=3D"ltr" style=3D"list-style-type:disc;font-size:15p=
x;font-family:Arial;color:rgb(0,0,0);vertical-align:baseline;background-col=
or:transparent"><p dir=3D"ltr" style=3D"line-height:1.15;margin-top:0pt;mar=
gin-bottom:0pt"><span style=3D"font-size:15px;white-space:pre-wrap;backgrou=
nd-color:transparent">Diagnostics and other interactions that are tied to t=
he 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-heig=
ht:1.15;margin-top:0pt;margin-bottom:0pt"><span style=3D"font-size:15px;fon=
t-family:Arial;color:rgb(0,0,0);white-space:pre-wrap;background-color:trans=
parent">This proposal would allow for the following code:</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><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 file =3D file_open_rlock=
("data_snippet"<wbr>);</span></p><p dir=3D"ltr" style=3D"line-height:1.15;m=
argin-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;backgr=
ound-color:transparent">au</span></p></span></div></blockquote></div>...</b=
lockquote></div>
<p></p>
-- <br />
<br />
--- <br />
You received this message because you are subscribed to the Google Groups &=
quot;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"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_143_1479981392.1414167279847--
.
Author: Jim Porter <jvp4846@g.rit.edu>
Date: Fri, 24 Oct 2014 01:08:53 -0500
Raw View
On 10/24/2014 1:01 AM, contact@ncomputers.org wrote:
> I searched *optional.hpp* and found this code:
>
> http://www.boost.org/doc/libs/1_56_0/boost/optional/optional.hpp
>
> Is this which you are using?
You might want to consult the paper proposing that optional be
standardized:
<http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n4082.pdf>.
libc++ also has an implementation of n4082's optional.
- Jim
--
---
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/.
.
Author: Bjorn Reese <breese@mail1.stofanet.dk>
Date: Fri, 24 Oct 2014 12:15:36 +0200
Raw View
On 10/24/2014 08:01 AM, contact@ncomputers.org wrote:
> http://www.boost.org/doc/libs/1_56_0/boost/optional/optional.hpp
>
> Is this which you are using?
I think Daniel was refering to the upcoming std::experiement::optional
[1], but yes it does originate from Boost.Optional.
[1] http://www.open-std.org/JTC1/sc22/wg21/docs/papers/2013/n3793.html
--
---
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/.
.
Author: robinsfr@gmail.com
Date: Sat, 1 Nov 2014 06:23:27 -0700 (PDT)
Raw View
------=_Part_483_65691817.1414848208025
Content-Type: text/plain; charset=UTF-8
Consider 'finalize' and 'dispose' as a candidate words too, as they are
shorter and has some precedent in other languages (Java and C#). I like
your ambition of having a consistent way to finalize a resource without
needing to remember the specific method names for each different type
(Close a handle but Free that thing and Destroy that other thing), and
introducing artificial scope via braces is just awkward sometimes. The
common case where I encounter this is when needing to briefly lock a
section of code for reading a variable, which makes braces weird because
you actually want to *keep* the scope of the object being read under lock.
What I want to do:
....
LockHolder lockHolder(object.GetLock());
String s = object.GetString();
finalize lockHolder;
....
What I end up doing:
....
String s;
{
LockHolder lockHolder(object.GetLock());
s = object.GetString();
}
....
The assignment is trivial in this case for a std::string, but declaring a
variable first with the default constructor only to replace it later is
silly.
--
---
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/.
------=_Part_483_65691817.1414848208025
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr"><div>Consider 'finalize' and 'dispose' as a candidate word=
s too, as they are shorter and has some precedent in other languages (Java =
and C#). I like your ambition of having a consistent way to finalize a reso=
urce without needing to remember the specific method names for each differe=
nt type (Close a handle but Free that thing and Destroy that other thing), =
and introducing artificial scope via braces is just awkward sometimes. The =
common case where I encounter this is when needing to briefly lock a sectio=
n of code for reading a variable, which makes braces weird because you actu=
ally want to <em>keep</em> the scope of the object being read under lock.</=
div><div><br></div><div>What I want to do:</div><div><font face=3D"courier =
new,monospace">...</font></div><div><font face=3D"courier new,monospace">&n=
bsp; LockHolder lockHolder(object.GetLock());</font></div><div><font=
face=3D"courier new,monospace"> String s =3D object.GetString=
();</font></div><div><font face=3D"courier new,monospace"> fin=
alize lockHolder;</font></div><div><font face=3D"courier new,monospace">...=
</font></div><div><font face=3D"courier new,monospace"><br></font></div><di=
v>What I end up doing:</div><div><font face=3D"courier new,monospace">...</=
font></div><div><font face=3D"courier new,monospace"> String s=
;</font></div><div><font face=3D"courier new,monospace"> {</fo=
nt></div><div><font face=3D"courier new,monospace"> &nb=
sp; LockHolder lockHolder(object.GetLock());</font></div><div><font face=3D=
"courier new,monospace"> s =3D object.GetString(=
);</font></div><div><font face=3D"courier new,monospace"> }</f=
ont></div><div><font face=3D"courier new,monospace">...</font></div><div><b=
r></div><div>The assignment is trivial in this case for a std::string, but =
declaring a variable first with the default constructor only to replace it =
later is silly.<font face=3D"courier new,monospace"><br></font></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" 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_483_65691817.1414848208025--
.