Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?

Re: Context aware functions - best practices?

by Zaxo (Archbishop)
on Jan 14, 2003 at 18:48 UTC ( #226923=note: print w/ replies, xml ) Need Help??

in reply to Context aware functions - best practices?

I think the wantarray solution is fine, and not all that awkward. That's what wantarray is for.

I think I can make a case for scalar foo LIST to return the last element of the result return wantarray ? @arr : $arr[-1];
instead of the first. A comma sequence behaves that way in scalar context, so that is the ordinary precedent competing with array count for behavior in scalar context.

A third possibility is to return a reference to the generated array. Some modules do that, but it is clearly not desired here.

No, I don't think you missed anything.

After Compline,

Comment on Re: Context aware functions - best practices?
Download Code
Replies are listed 'Best First'.
Re^2: Context aware functions - best practices?
by Aristotle (Chancellor) on Jan 14, 2003 at 19:02 UTC
    Thanks for the well thought out response. I hadn't even though about -1, but I accept the argument. "Awkward" was probably the wrong term - really I should have written "verbose" instead. I was just wondering if the same behaviour is possible to achieve in a more concise way.

    Makeshifts last the longest.

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (6)
As of 2015-12-01 09:26 GMT
Find Nodes?
    Voting Booth?

    What would be the most significant thing to happen if a rope (or wire) tied the Earth and the Moon together?

    Results (797 votes), past polls