3 ms·
The D Language has scope(exit), instead of defer. Example: scope(exit) writeln("3"); writeln("1"); writeln("2"); Output: 1 2 3
by crazypython 6y ago
The D Language has scope(exit), instead of defer. Example:
scope(exit) writeln("3");
writeln("1");
writeln("2");
Output:
1
2
3
- grok22 6y agoThe article references 'defer' being in several newer languages, but seems to have missed the 'scope' implementation in the D language which I think was implemented long before the other languages got their 'defer' feature.
- lerno 6y agoNo, I'm aware of it. GCC also has a similar feature as a C extension. I picked those languages because they very clearly use the same keyword.