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

Comma Operator

Thread Next
From:
Joe Gottman
Date:
January 20, 2004 18:15
Subject:
Comma Operator
Message ID:
000b01c3dfc4$bab7d620$e58f8445@carolina.rr.com
   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


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About