in reply to Returning undef: The point I would like Damian to reconsider
Don't change subroutine results based on list or scalar context.If I were trying to follow that advice, what should I do if a subroutine that returns a list in a list context gets called instead in a scalar or void context? "die"?
Just trying to think this through.
Or did you actually mean "if your subroutine naturally returns a scalar, be sure to return that same scalar in a list context unless otherwise documented" or something convoluted like that?
And the timing for this couldn't be better... I'm just now putting the finishing touches on the Perl Best Practices full-day course that I'm presenting at YAPC::NA next week, and have had my own thoughts on many issues such as these during the writing of the course.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Returning undef: The point I would like Damian to reconsider
by jdporter (Paladin) on Jun 22, 2007 at 21:57 UTC | |
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 | |
| |
|
Re^2: Returning undef: The point I would like Damian to reconsider
by martin (Friar) on Jun 23, 2007 at 09:03 UTC | |
by merlyn (Sage) on Jun 23, 2007 at 18:13 UTC |