Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re^3: Is there any difference between prototype % and @ ?

by AnomalousMonk (Abbot)
on Feb 22, 2013 at 20:33 UTC ( #1020223=note: print w/ replies, xml ) Need Help??


in reply to Re^2: Is there any difference between prototype % and @ ?
in thread Is there any difference between prototype % and @ ?

... an even number of arguments...
I will add a manual check.

What are you doing with the arguments subsumed under the  % prototype? Well, right now you're probably just writing test code to check the behavior of the prototype, but in a 'real world' case, would you not assign these arguments to a hash? What else? If assigning an odd number of elements to a hash, Perl warns (if warnings are enabled) with no separate check necessary. Granted, the warning doesn't stem from the prototype checking system, but...

>perl -wMstrict -le "sub H (&%) { my ($cr, %h) = @_; $cr->(%h); } ;; H { print @_; } qw(a 1 b); " Odd number of elements in hash assignment at -e line 1. Use of uninitialized value $_[3] in print at -e line 1. a1b


Comment on Re^3: Is there any difference between prototype % and @ ?
Select or Download Code
Re^4: Is there any difference between prototype % and @ ?
by LanX (Canon) on Feb 22, 2013 at 20:52 UTC
    not in this case, cause I want to have it as fast and memory saving as possible.

    thats why I'm splicing... though using indexes $_[$i] should be even faster...

    just check the post I linked in the OP

    Cheers Rolf

      not in this case, cause I want to have it as fast and memory saving as possible.

      Then why create a list from the hash in the first place?


      With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
      Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
      "Science is about questioning the status quo. Questioning authority".
      In the absence of evidence, opinion is indistinguishable from prejudice.
        > Then why create a list from the hash in the first place?

        It's meant to be compatible with the standard interface!

        You might remember that map, sort and grep can be chained and they always accept and return lists...

        Cheers Rolf

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (7)
As of 2014-10-21 03:23 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    For retirement, I am banking on:










    Results (95 votes), past polls