Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re^3: perl5 vs perl6

by duff (Parson)
on Jan 06, 2005 at 21:46 UTC ( [id://420106]=note: print w/replies, xml ) Need Help??


in reply to Re^2: perl5 vs perl6
in thread perl5 vs perl6

let is like temp but it's only useful inside of rules. If the rule succeeds, then the variable keeps the hypothesized value. If the rule fails, then the variable loses its hypothesized value and thus reverts back to whatever value it had before (if any).

This is all as far as I know anyway. But then, things I thought I knew about rules have changed at least 2 times since I learned them, so who really knows anyway? ;-)

Replies are listed 'Best First'.
Re^4: perl5 vs perl6
by blazar (Canon) on Jan 09, 2005 at 14:07 UTC
    let is like temp but it's only useful inside of rules. If the rule succeeds, then the variable keeps the hypothesized value. If the rule fails, then the variable loses its hypothesized value and thus reverts back to whatever value it had before (if any).
    I've quickly searched around and indeed it seems to be so. That is, let is to be used in closures embedded in rules.

    Due to the deep analogy between rules and subs I wonder wether the same mechanism could be made to work also for the latter ones (using the return value for success): I do not see any immediate use, but I bet someone could find one.

    Well, however this is probably not best discussed here...

      Sigh. A let may certainly be used in ordinary blocks. See http://dev.perl.org/perl6/synopsis/S04.html for the definition of successful exit. The KEEP and UNDO blocks use the same definition, and are arguably part of the same underlying mechanism. You can view a let as a temp that merely does UNDO instead of LEAVE.
        Sigh. A let may certainly be used in ordinary blocks. See
        Sigh. So it is indeed just like I remembered in the first place, which is good news anyway, as I consider this to be a very desirable feature...

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://420106]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others lurking in the Monastery: (4)
As of 2024-04-24 06:55 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found