Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re^4: What to test in a new module

by swl (Parson)
on Jul 08, 2023 at 05:56 UTC ( #11153318=note: print w/replies, xml ) Need Help??


in reply to Re^3: What to test in a new module
in thread What to test in a new module

Thanks for the clarification. Two other points, which you are probably well aware of but some readers might not be:

return; and return(); are the same, although the brackets do make it more visually distinct and perhaps that's your point.

return; in list context returns the empty list. This means it is effectively the same as return wantarray ? () : undef; unless it is called in void context. Your use of it when not expecting a return value implies void context, though, so perhaps this point is moot.

Replies are listed 'Best First'.
Re^5: What to test in a new module
by jdporter (Chancellor) on Jul 10, 2023 at 14:14 UTC
    the brackets do make it more visually distinct and perhaps that's your point.

    That is precisely my point.

    It isn't obvious that return; returns undef, so I don't depend on that. That is, I don't use that construction when that's what I want to do.

      > It isn't obvious that return; returns undef

      It doesn't. It returns undef in a scalar context, but an empty list in a list context.

      map{substr$_->[0],$_->[1]||0,1}[\*||{},3],[[]],[ref qr-1,-,-1],[{}],[sub{}^*ARGV,3]

        Whatever. It returns the same as return();
        The point is that what it returns isn't obvious — at least, not nearly as obvious as return(); ... so it's worth the extra two characters (imho).

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others chanting in the Monastery: (10)
As of 2023-12-11 12:01 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    What's your preferred 'use VERSION' for new CPAN modules in 2023?











    Results (41 votes). Check out past polls.

    Notices?