On Thu, 2005-02-10 at 11:59, Luke Palmer wrote:

> There's been some discussion about bringing a syntax back for that
> recently, but I haven't really been paying attention.  Anyway, this is
> pretty clear:
> 
>     loop {
>         $foo = readline;
>         do { stuff :with($foo) };
>         last unless $foo;
>     }

Well, yes it's clear, but then you run into the problem where your code
looks like:

        while stuff() {
                more_stuff();
        }
        loop {
                other_more_stuff();
                last unless other_stuff();
        }

and then you want to add something like:

        next if things();

to both... you have to do it in two ways. The Perl 6ish way of dealing
with this is:

        while stuff() {
                next if things();
                more_stuff();
        }
        loop {
                next if other_things();
                other_more_stuff();
                NEXT { last unless other_stuff(); }
        }

I think Larry's contention has been that loop is all you really need,
and everything else is a macro. If you really want dowhile, then it's
something like (making up macro example on the fly, and probably wrong
here...):

        macro infix:dowhile (Code $block, Bool $cond) {
                loop { $block.(); NEXT { last unless $cond.() } }
        }

        {
                next if other_things();
                other_more_stuff();
        } dowhile other_stuff();

Of course, that assumes that an expanded macro will, by default, handle
the case when you pass it code that invokes a loop control, expecting to
control the loop inside the macro first.


-- 
â 781-324-3772
â [EMAIL PROTECTED]
â http://www.ajs.com/~ajs

Reply via email to