Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re: What should be returned in scalar context? (frog)

by tye (Sage)
on Dec 03, 2003 at 07:14 UTC ( [id://311849]=note: print w/replies, xml ) Need Help??


in reply to What should be returned in scalar context?

The only default I can think of that makes much sense to me is:

croak ... if ! wantarray;

So, if you haven't taken the time to decide what should be returned by your list-returning function when used in a scalar context, it makes some sense to prevent people from using your function that way (yet), perhaps even telling the user that you haven't decided what that is supposed to mean yet.

After you've used the function for a while, a sane choice may well become rather obvious and you can put the new scalar-context behavior in place, quite confident that you aren't breaking any existing code.

                - tye

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://311849]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others rifling through the Monastery: (5)
As of 2024-04-24 07:38 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found