Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re^3: shift vs @_

by exussum0 (Vicar)
on Oct 06, 2006 at 14:39 UTC ( #576687=note: print w/replies, xml ) Need Help??


in reply to Re^2: shift vs @_
in thread shift vs @_

Um, yeah. But it doesn't prevent me from being human and making a mistake. It's harder to get it wrong w/ a progression of shifts.

Replies are listed 'Best First'.
Re^4: shift vs @_
by radiantmatrix (Parson) on Oct 06, 2006 at 16:36 UTC

    But it doesn't prevent me from being human and making a mistake.

    Ok, firstly, you said that you can't easily do what you wanted, not that it was easy to make a mistake.

    Secondly, attempting my $x, $y = @_ with strict in place (which is best practice anyhow) produces:

    Global symbol "$y" requires explicit package name
    Which would be a pretty big clue to me that something was wrong (you aren't creating a lexical $y with my $x, $y). Doing the same thing with warnings turned on (another best practice) results in:
    Parentheses missing around "my" list

    I'd say that pretty well prevents you from making this mistake, anyhow.

    <radiant.matrix>
    A collection of thoughts and links from the minds of geeks
    The Code that can be seen is not the true Code
    I haven't found a problem yet that can't be solved by a well-placed trebuchet
      Frequently, I use strict and warnings, but there are times I don't. And sometimes prototypes become production code. They get copy pasted by some mad madness. It's possible to also do my $x = @_, which will work w/ strict and warnings.

      Unless I have a good reason, I prefer shifts. It's just a preference as defensive programming. 'cause one day, somehow a my $x, $y = @_, and someone will forget to use strict. And I'll be part blame for the assignment, someone else for the warnings and strictness.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://576687]
help
Chatterbox?
[Corion]: ambrus: Details ;)
[ambrus]: Like <c>{ package AnyEvent::Impl:: Prima; use Prima; sub io{ my($s,%r)=@_; Prima::File->new( file=>$r{fh},mask =>("w"eq$r{poll}? fe::Write():fe:: Read())|fe:: Exception,onRead =>$r{cb},onWrite =>$r{cb}, onException=>$r{cb }) } sub timer { ... } push @AnyEvent::REGI
[ambrus]: argh, too long, let me try on scratchpad
[Corion]: . o O ( I seem to have improved my skills of getting other people to write code for me )
[ambrus]: ambrus's scratchpad

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (10)
As of 2016-12-08 12:39 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    On a regular basis, I'm most likely to spy upon:













    Results (141 votes). Check out past polls.