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.
I don't know how to not interpret that as "being a 'list' means that it will return the last value in a scalar context". And I don't think the scare quotes make that more clear or less misleading. And using that with "always return" makes it more confusing to me.
As for what is least surprising, I find that it depends completely on what the function does. Having scalar( caller() ) be the same as ( caller )[-1] would make no sense and so would certainly be surprising. Returning the first item, returning a reference to an array, or returning a string that includes all of the items are three behaviors that I often find appropriate. Returning the last item is not something I choose often.
- tye
In reply to Re^7: Returning undef: The point I would like Damian to reconsider ("list"?)
by tye
in thread Returning undef: The point I would like Damian to reconsider
by martin
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |