On Tue, Nov 18, 2003 at 11:14:54AM -0500, Dan Sugalski wrote:
: On Tue, 18 Nov 2003, Simon Cozens wrote:
: 
: > [EMAIL PROTECTED] (Austin Hastings) writes:
: > > This is what I was talking about when I mentioned being able to do:
: > >   &cleanup .= { push @moves: [$i, $j]; }
: >
: > This reminds me of something I thought the other day might be useful:
: >
: >     $cleanup = bless {}, class {
: >         method DESTROY { ... }
: >     };
: >
: > Of course, it probably wouldn't work in this context because you couldn't
: > guarantee that the destructor will be called at the point of loop exit, but I
: > like the anonymous class syntax anyway.
: 
:      $cleanup = bless {}, class : impatient {
:          method DESTROY { ... }
:      };
: 
: That'll probably do it, at the expense of extra runtime block exit
: overhead until the object dies. If you just want a block exit action,
: then:
: 
:  add_block_exit_action(\&foo);
: 
: or something similar will do it. (Though we could add new syntax for it if
: you really want... :-)

Why are you guys dragging all this Perl 5 syntax back into Perl 6?
There is no bless function in Perl 6--it's a method.  Class traits
are introduced with "is", not ":".  And you don't need to backwhack
the &foo.

Sheesh.

Oh, by the way, if you want to return a value from a control structure,
you will have to do so explicitly by putting "do {...}" around it.
We will certainly *not* allow both of these:

    return if $a;
    return if $a {...};

Shudder.  That is so unreadable.  It doesn't even work in English.

And nested modifiers are still quite illegal in Standard Perl 6.

As for the original question that started this whole silly thread,
control structures that return values should probably be considered
some kind of generator, and have an explicit "yield"-like statement
that is orthogonal to "last" and such.  Such a generator would be
explicitly marked, as with "do {...}" above, only different.  The
inside of such a generator after the loop is the natural place
to say what happens if nothing in the loop "works".

It's important with unusual control structures to say what you mean
up front.  Making the reader back up and reparse is antisocial.
Which is why we allow statement modifiers only in moderation.

Larry

Reply via email to