Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris

Re^4: More efficient dereferencing of a subroutine return

by parv (Priest)
on Feb 18, 2013 at 00:05 UTC ( #1019241=note: print w/replies, xml ) Need Help??

in reply to Re^3: More efficient dereferencing of a subroutine return
in thread More efficient dereferencing of a subroutine return

Did you, and the one before you, missed the part where I wrote about the case of undef being returned, as in ...

use strict; my @p = @{ list() }; sub list { return undef; }


Replies are listed 'Best First'.
Re^5: More efficient dereferencing of a subroutine return
by Anonymous Monk on Feb 18, 2013 at 00:24 UTC

    That is what you said, but look at the OP's code, its always  return \@array which can never be undef

    an empty array is better than undef

      It seems you and I read the representation of the problem differently. Your reply presumes that every return from sub is always a return of an array reference. (If that promise is made to the user of the sub, then I have no disagreement with direct dereferencing of the return value.) I think of the value returned being an array reference where possible; else, nothing or undef is returned.

        Look, no temporaries, no fatal :) my @stuff = eval { @{ func() } };

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1019241]
[choroba]: that's 2012
[zentara]: I just acquired a computer with the card type, and wondered if it was best to stick with the open-source code or use NVIDIA's proprietary code
[zentara]: do you feel good about a non-open-source code, being in control of your display functions?
[choroba]: If you're not going to play 3d games on it, using the open source driver should be enough
[zentara]: choroba that is true, and the wise choice, but I want to see how fast I can get fglrx3dspheres to run... just as an intellectual challenge :-)

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (10)
As of 2017-05-26 14:00 GMT
Find Nodes?
    Voting Booth?