un-defer, re-defer, defer.is_active #473
Labels
breaking
Implementing this issue could cause existing code to no longer compile or have different behavior.
enhancement
Solving this issue will likely involve adding new logic or components to the codebase.
proposal
This issue suggests modifications. If it also has the "accepted" label then it is planned.
Milestone
defer
feature was initially invented in year 2000 by Andrei Alexandrescu and Petru Marginean, under namescope guard
. ( http://www.drdobbs.com/cpp/generic-change-the-way-you-write-excepti/184403758 )Alexandrescu later introduced it into D language, in three forms, no less. Language Go brought up keyword
defer
.Say we have a connection, want to close it at the end of lexical block, but it can be closed only once. Solution is simple, use a helper flag:
Though simple it has some problems:
defer
is high level functionality, fiddling with a flag is the lowest possible level.defer
) is hidden.My suggestion is to provide the inversion to
defer
as language feature:or named alternative:
No easy to misuse helper flags anymore!
Notes:
un-defer
contains minus. Why not? It is more readable.un-defer
could be used only in case when there's just single unnameddefer
, otherwise name is required.It is possible to go even further and add
re-defer
functionality.or similarly named variant.
Notes:
un-defer
are also valid here.un-defer
andre-defer
in any way.As things grew complicated support for
assert
could be added:Named variant:
Notes:
assert
. Making it general would open Hell's gate.To support
re-defer
there could be some way to print current defer action as a string (string with code inside) in debugger and/or IDE.The text was updated successfully, but these errors were encountered: