On Tue, Jan 20, 2004 at 08:12:28PM -0800, Jonathan Lang wrote: : Joe Gottman wrote: : > 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? : : Not that I'm aware of. For the most part, the previous discussion was : focusing on what to replace the comma with in the case of "discard all but : the last result", and my impression was that any ruling on the change : would likely be contingent on the presence or absence of a suitable : replacement.
I'm a little frustrated because I feel like I've ruled on it several times, but it never seems to "stick". I guess that's because it was never ruled in an Apocalypse, just in email. But I'm sure I'm on the record somewhere saying that I think [-1] is sufficient to pick out the last element of a list. If nothing else, just a couple of days ago, but I'm sure I also said it more than once in ancient times. : That said, : : > 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. : : I do like this suggestion. In the majority of cases where I've used the : comma operator, I've either enclosed the whole thing in parentheses to : turn it into a list, or I've treated it as a sequence of operators where : even the last result got discarded. I've rarely been interested in just : the last result, and I wouldn't mind that functionality being provided by : means of a C<last> function which evaluates the list parameters for their : side effects and returns the value of the last list parameter. Well, a C<last> function (or method) would be redundant with [-1], though I'm not totally opposed to redundancy. ["You can say that again."] Larry