then it should always return a "list", even in scalar context, i.e. if called in scalar context return the last value in its return expression.Ugh, that's not possible. You cannot return a list in a scalar context. Ever.
You can type:
But that's not "returning a list in a scalar context", even if called in a scalar context. It's returning a scalar in a scalar context, by evaluating that comma-expression in a scalar context, getting the result 101.return (99, 100, 101);
I know you know that, but sloppy language here gets us running around in circles.
See my On Scalar Context for samples of many things that "listy" things do in a scalar context. Based on that, I don't see how "last thing" is any more intuitive than "first thing" or "number of elements" (the three main candidates).
In reply to Re^3: Returning undef: The point I would like Damian to reconsider
by merlyn
in thread Returning undef: The point I would like Damian to reconsider
by martin
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |