On Mon, 2002-04-29 at 15:54, Jonathan Scott Duff wrote:
> On Mon, Apr 29, 2002 at 03:30:40PM -0400, Aaron Sherman wrote:
> > On Mon, 2002-04-29 at 10:41, Jonathan Scott Duff wrote:
> > > On Mon, Apr 29, 2002 at 10:26:26AM -0400, Aaron Sherman wrote:
> > > > I would expect that to be "elsuntil", but as we're dropping "until" from
> > > > the language, it's a moot point.
> > >
> > > Er, what?!? Who said we're dropping "until"? Did I miss something?
> >
> > Well, if there's no while (replaced by generic "loop", per Apoc4) why
> > would there be an until?
>
> Larry didn't say "loop" was replacing "while". He said that the magic
> "do {} while" was going away to be replaced by "loop". "while" and
> "until" (both as loops and modifiers) will still be around AFAIK.
>
> > 1. Larry says loops will have "ELSE blocks" inside them.
>
> Did he say that? Or was it inferred from NEXT, LAST, etc. by others?
No he didn't. Again, flaky memory on my part. What DAMIAN said was:
"Larry has been mulling over whether various types of loop should be
allowed to take C<else> blocks to accomplish this."
So, you can see where my confusion came from. It's not clear if this was
suggesting loop{else{}} or loop{}else{}, but either way, this was the
origin of the discussion.
> > 4. I point out that elsif isn't so bad, and perhaps there should be an
> > array of other "else" options.
>
> And I say, why have several specific things when you can have 1
> generalized thing that does the same job. (I'm not going to describe it
> beyond that. It's up to Larry+Damian to define the shape of the thing)
Well then, I guess we should dump "elsif" from if too. After all, it
could all be done with nested blocks of if/else....
If we're to keep if the same, and add an else to loops, I think the
syntax should be unified.
You would then see code like:
unless $fh = $x.open() {
die "$0: Cannot open $x";
} elswhile $fh.getline() -> $_ {
print;
} else {
die "$0: There were no lines to read from $x!\n";
}
Which is as clean and elegant as it gets, IMHO.
> > So, the answer to your question is: yes, I do propose that there should
> > be an elsif, elsloop and elsfor. That's it. Three words, not an
> > expansive list of ever-more-complex words.
>
> You're just weird. :)
Thanks ;)
> > Now, I agree that "else for" might make more sense, but it's very ugly
> > on the grammar (given that we don't allow free statements like C does).
>
> Hey, perl 6 is supposed to be optimized for the programmer, not the
> perl parser ;-)
I agree. This is why I think conditionals and loops should have roughly
the same syntax.
Introducing a major twist in the grammar just so that loops and
conditionals can be different, seems to hurt both camps equally and
benefit none.