develooper Front page | perl.perl6.language | Postings from January 2004

Comma Operator

Thread Next
Joe Gottman
January 20, 2004 18:15
Comma Operator
Message ID:
   About a month ago, a thread here suggested that we change the meaning of
the comma operator.  Currently, in scalar context the expression
    foo(), bar()
means "evaluate foo(), discard the result, then return the value of bar()".
It was suggested that this be changed to return the 2-element array (foo(),
bar()).  Has Larry ruled on this yet?

    By the way, even if we do make this change, I think that in void context
the expression
    foo(), bar()
should still simply evaluate its parameters in order for their side-effects.
This would allow comma expressions to remain as-is in loop statements
(formerly for statements), which is where most of them are found anyway.
For instance
    loop (my ($x = 0, $y = 10); $x < $y; ++$x, --$y) {...}

Joe Gottman

Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About