|P is for Practical|
Re: (Perl6) Groking Continuationsby John M. Dlugosz (Monsignor)
|on Apr 10, 2003 at 17:52 UTC||Need Help??|
The interesting part about Perl and Prolog and Continuations... oh my! is that the variables are put back to what they were after performing the continuation.
That is, given two constructs x and y, imply x, y, xx where xx is implicit in x and is to be done after y. This is straightforward if y is a closure passed to a function x.
But here is an idea to help eliminate so many (nested) closures.
Have the Unify leave behind an object that goes out of scope to perform xx. As a first cut, that would look like this:
It still needs too much extra syntax, but the point is that you don't need a closure, and can easily have more than one thing to do inside the scope of the unification, and don't need an exception to indicate success/failure and get back to ordinary procedural code.
In Perl 6, the DESTROY can't be relied upon to be called at the close brace, but a function can add exit actions to the callers scope so that works just as well and avoids the need for $nameless and extra parens.
In C++, which doesn't have closures, you can't declare the variable inside the parens but you don't need to give it a name either if the actions are joined together with commas or &&'s, since a temporary will be destructed at the end of the complete statement containing it.
In C#, there is no mechanism for prompt destruction actions to be called. The scoped lock is built-in and a similar mechanism can't be written within the language (a symptom that it's incomplete).