Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options

comment on

( #3333=superdoc: print w/replies, xml ) 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:

{ # extra scope (my $nameless= unify ($var, "frank")) && print "This is done if var unified with frank."; } # unbinding takes place here.
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).


In reply to Re: (Perl6) Groking Continuations by John M. Dlugosz
in thread (Perl6) Groking Continuations by crenz

Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":

  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or or How to display code and escape characters are good places to start.
Log In?

What's my password?
Create A New User
Domain Nodelet?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (3)
As of 2022-05-26 21:14 GMT
Find Nodes?
    Voting Booth?
    Do you prefer to work remotely?

    Results (94 votes). Check out past polls.