Lisp for example has unwind-protect, which is guaranteed to run the unwind code when you leave its scope in which way whatever (be it an exception or a return). So this is a reliable way of running clean-up code at the end of a code block.
Re:Learn X in Y minutes – Tcl
by a8da6b0c91d on Tuesday August 25, 2015 @04:49PM
(#10119352)
Many scripting languages in practice do reference counting GC that will reliably and deterministically clean up resources other than memory.
"Many" includes Tcl there. I have no idea why you think differently. Tcl has had it since the 8.X series started (at least).
Re:Learn X in Y minutes – Tcl
by a8da6b0c91d on Tuesday August 25, 2015 @06:32PM
(#10119876)
Not for tcloo objects, channels and file handles. I don't think you get it. In sane languages like C++ you can expect a destructor to call itself no matter where a function exited.
C++ is not a scripting language. Give me a scripting language that does that so I can research and compare.
Re:Learn X in Y minutes – Tcl
by a8da6b0c91d on Tuesday August 25, 2015 @07:51PM
(#10120218)
perl:
sub do_stuff {
my $thing = Thing->new; # no need to manually destroy thing. Its DESTROY method will be called at the closing brace.
}Cool...now I get to play. Perl does it because it goes out of scope once the sub is run. I am pretty sure you can tell TclOO to do the same thing (play time) if it already doesn't do that.
In the end, they all make trade offs depending on the "whim" of the language designer.
Re:Learn X in Y minutes – Tcl
by a8da6b0c91d on Tuesday August 25, 2015 @09:35PM
(#10120504)
Jesus Christ, you don't even know tcl. Why are you blathering on here? No, tcloo objects are not garbage collected. That's the whole point here.
Yeah just blathering. Carry on.
Re:Learn X in Y minutes – Tcl
by AnimalMuppet on Wednesday August 26, 2015 @12:43PM
(#10124210)
So, about four posts before this one, you said:
> Many scripting languages in practice do reference counting GC that will reliably and deterministically clean up resources other than memory.
When challenged, you offered one. So, is this a Perl-only thing, or can you give other examples?
So: What language(s) did you have in mind that do this right?