> Mailing-List: contact [EMAIL PROTECTED]; run by ezmlm > Date: Fri, 15 Nov 2002 07:37:51 +1100 (EST) > From: "Timothy S. Nelson" <[EMAIL PROTECTED]> > Sender: [EMAIL PROTECTED] > X-SMTPD: qpsmtpd/0.12, http://develooper.com/code/qpsmtpd/ > > Here's the next part to the Control Structures message I sent before. > > The next part is to apply the same idea to loop. Please note that > this syntax conflicts with stuff already in Perl, but it's a bit clearer what > I mean when I do it this way; the question is, do we scrap my idea, or the > other syntax? :) > > I'll begin with a few words of explanation of what follows. First, > you normally wouldn't spread it out this much. Second, each line is > optional, except "loop" and { blockL }. > > ---------------------------------------------------------------------- > loop > parallel > first { BLOCKF } > each [ actual ] [ $key [ => $value ] ] (@array|%hash) > while ( EXPR ) > count [ $autocount ] [ ($start, $end, $step) ] > nest { BLOCKT } > { BLOCKL } > next { BLOCKX } > all { BLOCKA } > any { BLOCKB } > some { BLOCKS } > none { BLOCKN } > ----------------------------------------------------------------------
Do you grok the current C<for> syntax? Do you know about the FIRST, NEXT, and LAST blocks? If so, you'll easily see that your million-and-a-half keywords are complicating what we already have. for parallel(<>, 0..Inf) -> $line, $count { FIRST { $line //= "#!/usr/bin/perl" } # processing... NEXT { print STDERR "Next line...\n" } LAST { print STDERR "Done\n" } } That 'example' (ignoring the fact that examples usually have some purpose ;) has all the useful stuff from your list, and IMO is more comprehensible than a LISPish do-ish loop. Also, keep in mind that that C<parallel> function can be any (possibly user-defined) function. I really like that interface. Also keep in mind that that may not be The Interface :( i.e. still under debate ). The only thing it doesn't cover is C<nest>, which, in practical situations, isn't all that useful anyway. It's cleaner just to nest manually. Luke