Sign In/My Account | View Cart  
advertisement


Listen Print

Apocalypse 4
by Larry Wall | Pages: 1, 2, 3, 4, 5, 6, 7, 8, 9

Editor's Note: this Apocalypse is out of date and remains here for historic reasons. See Synopsis 04 for the latest information.

Withdrawn RFCs

RFC 063: Exception handling syntax

RFC 113: Better constants and constant folding


Other decisions

C-style for loop

Due to syntactic ambiguities with the new for syntax of Perl 6, the generalized C-style for loop is going to get its keyword changed to loop. And for will now always mean "foreach". The expression "pill" is now optional, so instead of writing an infinite loop like this:

    for (;;) {
        ...
    }

you can now write it like this:

    loop {
        ...
    }

C-style do {} while EXPR no longer supported

In Perl 5, when you used a while statement modifier on a statement consisting of nothing but a do {}, something magical happened, and the block would be evaluated once before the condition was evaluated. This special-cased construct, seldom used and often misunderstood, will no longer be in Perl 6, and in fact will produce a compile-time error to prevent people from trying to use it. Where Perl 5 code has this:

    do {
        ...
    } while CONDITION;

Perl 6 code will use a construct in which the control flow is more explicit:

    loop {
        ...
        last unless CONDITION;
    }

Bare blocks

In Perl 5, bare blocks (blocks used as statements) are once-through loops. In Perl 6, blocks are closures. It would be possible to automatically execute any closure in void context, but unfortunately, when a closure is used as the final statement in an outer block, it's ambiguous as to whether you wanted to return or execute the closure. Therefore the use of a closure at the statement level will be considered an error, whether or not it's in a void context. Use do {} for a "once" block, and an explicit return or sub when you want to return a reference to the closure.

continue block

The continue block changes its name to NEXT and moves inside the block it modifies, to work like POST blocks. Among other things, this allows NEXT blocks to refer to lexical variables declared within the loop, provided the NEXT block is place after them. The generalized loop:

    loop (EXPR1; EXPR2; EXPR3) { ... }

can now be defined as equivalent to:

    EXPR1;
    while EXPR2 {
        NEXT { EXPR3 }
        ...
    }

(except that any variable declared in EXPR3 would have different lexical scope). The NEXT block is called only before attempting the next iteration of the loop. It is not called when the loop is done and about to exit. Use a POST for that.

Well, that about wraps it up for now. You might be interesting to know that I'm posting this from the second sesquiannual Perl Whirl cruise, on board the Veendam, somewhere in the Carribean. If the ship disappears in the Bermuda Triangle, you won't have to worry about the upcoming Exegesis, since Damian is also board. But for now, Perl 6 is cruising along, the weather's wonderful, wish you were here.