Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling

Re: Re: Re: Re: My coding guidelines

by sauoq (Abbot)
on Dec 01, 2002 at 05:36 UTC ( #216731=note: print w/replies, xml ) Need Help??

in reply to Re: Re: Re: My coding guidelines
in thread My coding guidelines

This save you from adding extra shifts or assigning extra variables when you add a value to be be passed in. So you don't have to my $x=$_[0]; my $y=shift;.

I don't really understand the point you are trying to make with that statement.

Generally, I prefer my ($x) = @_; and, if a new parameter is later needed, I add it. So that would become my ($x, $y) = @_; when I add the second parameter.¹

By the way, the code example you gave is in error. It would result in $y containing the same value as $x.

¹ Those who saw my other response to Abigail-II in this thread might wonder about my use of whitespace with my ($x) as I indicated that I prefer alternatives to foo ($bar). I treat my, our, and local differently because they are different. They are keywords for declaring scope, they aren't functions.

"My two cents aren't worth a dime.";

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (10)
As of 2021-03-04 10:38 GMT
Find Nodes?
    Voting Booth?
    My favorite kind of desktop background is:

    Results (102 votes). Check out past polls.