Jonathan Lang <[EMAIL PROTECTED]> writes:

> Strictly from a grammatical perspective, I'd be much more comfortable with
> C<, then> instead of C<then> as the perl equivelent of the C-style comma:
> have the "then" keyword change the preceeding comma from a list
> constructor to an expression combiner.  From a parsing perspective,
> though, this would be a nightmare.  

Parsing Perl was nightmarish already before work started on Perl6.  If
we wanted a language that's easy to parse, we'd be using lisp, or
maybe assembly language.

Still, I'm not sure what the comma adds, other than extra[1]
punctuation.

This is different from its use in conditional sentences, since in that
case the protasis (if clause), being an introductory subordinate
clause, is usually set off from the rest of the sentence via a comma,
whether or not "then" is used to introduce the apodosis (then
clause).  It is common to see a comma before "then" for this reason,
but that is entirely a different use (and meaning) of "then".

Come to think of it, the frequent use of "then" in conditionals might
make it a bad choice for use in another way.

> Actually, the whole purpose of the C-style comma is to allow you to place
> multiple expressions in a place that's only designed to take one, such as
> the various divisions within a loop control set ("loop ($i = 0, $j = 1; $i
> < 10; $i++, $j*=2) {...}").  For something like this, you might be better
> off doing something like
>
>   last($a, $b, $c)
>
> (where last is a sub that takes a list of arguments, evaluates them one at
> a time, and returns the value of the last one).  Unfortunately, "last" is
> already in use by perl; so you'd have to think up another name for the
> sub, such as "final".  

Oh, like lisp's progn (except that final is a better name for it).

Perl5 programmers have been known to use xor for this, though of
course that is not the intended use of xor.

> where C[->] is read as "followed by".  You could even set up a
> right-to-left version, C[<-], but why bother?  

Oh, for aesthetic symetry, of course ;-)

[1] "Do one thing then do another" is valid SWE I think. "then" is not
    a coordinating conjunction like "and"; it's a special adverb of
    sorts, in a similar category with "because" (except that "because"
    is a subordinator; whereas, "then" does coordinate; but it is not
    a conjunction) or "so" (although "so" often is treated like a
    conjunction and takes the comma, which is an odd little wrinkle --
    but it does not always do this).  "then" can function as a
    coordinating adverb (like consequently and nonetheless and so on);
    in the case wherein it joins whole independent clauses it is
    preceded by a semicolon (as in "She went to the store; then she
    came home." -- if there were a comma in this case it would be
    after "then", not before), but it can also be used to coordinate
    the parts of a compound part of speech, e.g., a compound verb with
    the subject expressed only once (if at all; in the imperative mood
    the subject need not be expressed); in that case no punctuation is
    needed, as in "She went to the store then came home."  This last
    usage most closely fits the proposed way of using it in Perl, as
    in " (you) Go to the store then come straight home."

-- 
$;=sub{$/};@;=map{my($a,$b)=($_,$;);$;=sub{$a.$b->()}}
split//,"[EMAIL PROTECTED]/ --";$\=$ ;-> ();print$/

Reply via email to