3 ms·
If you actually use RAII, and write braces in a bit of an unorthodox style, the distinction disappears even further: { AutoFile file("c:/temp/foo.txt", "w"
by nightcracker 11y ago
If you actually use RAII, and write braces in a bit of an unorthodox style, the distinction disappears even further:
{ AutoFile file("c:/temp/foo.txt", "w");
fprintf(file, "Hello, world"); }
(with-open-file (f "c:/temp/foo.txt" "w")
(fprintf f "Hello, world"))
- noobermin 11y agoI honestly think explicit scopes, even though unorthodox, should become more of a thing. I personally do it in my C play projects to emphasize particular parts in a function as being independent "subordinate clauses", and with variables that only have a limited scope, but not being independent enough to be factored into a function--for example when the clause needs to be within reach of a label. In C++ with RAII, the "emphasis" makes even more sense, to the extent that it doesn't make things ugly.