in reply to Re: Returning undef: The point I would like Damian to reconsider
in thread Returning undef: The point I would like Damian to reconsider
In the past, when faced with this question, I've usually gone on the principle that if a function normally/ever gets called in list context, 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. This, imho, is the minimally surprising behavior in most scenarios, and is also easiest to code as you don't have to code for sensitivity to calling context. OTOH, obviously there may be times when you'd rather have some other behavior; the only other one you should "reasonably" implement is having it act like an array, i.e. return the return list length when called in scalar context. But even that would warrant documentation including several exclamation points. Any other behaviors should, I think, be limited strictly to internal function calls, not in a public interface.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Returning undef: The point I would like Damian to reconsider
by merlyn (Sage) on Jun 22, 2007 at 22:22 UTC | |
by jdporter (Paladin) on Jun 23, 2007 at 00:46 UTC | |
by tye (Sage) on Jun 23, 2007 at 01:02 UTC | |
by jdporter (Paladin) on Jun 23, 2007 at 18:53 UTC | |
by tye (Sage) on Jun 24, 2007 at 00:41 UTC | |
|