Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re^6: Autoboxing ... "Yes We Can" ( or how I learned to love TIMTOWTDI )

by educated_foo (Vicar)
on Dec 17, 2013 at 04:17 UTC ( #1067421=note: print w/ replies, xml ) Need Help??


in reply to Re^5: Autoboxing ... "Yes We Can" ( or how I learned to love TIMTOWTDI )
in thread Autoboxing ... "Yes We Can" ( or how I learned to love TIMTOWTDI ;)

multimethods?
Just some more terminology. A "method" is &{lookup($x, 'name')}($x, ...). A "multimethod" is just &{lookup($x, ..., 'name')}($x, ...)).
one of the peculiar sides of Perl is that plenty of build-ins internally work on references and but force you to dereference the argument manually.
each() *once* only worked on hashes, so it could complain at compile-time. Now it not only works on hashes and hash-refs, but also on arrays and array-refs, so if it gets a reference, it has to either guess (i.e. DWIM) or, in the current implementation, complain and refuse to do anything useful (i.e. "Type of argument to each on reference must be unblessed hashref or arrayref").


Comment on Re^6: Autoboxing ... "Yes We Can" ( or how I learned to love TIMTOWTDI )
Select or Download Code
Re^7: Autoboxing ... "Yes We Can" ( or how I learned to love TIMTOWTDI )
by LanX (Canon) on Dec 17, 2013 at 07:48 UTC
    > each()  once only worked on hashes,

    true, never thought about it, but each can handle such problems only at runtime now.

    So do you like or dislike it?

    I mean, we could drop the new behavior in favor of method-calls on scalars... ;-)

    update

    oh just noticed again, you alread said

    > no problem with auto-deref.

    Cheers Rolf

    ( addicted to the Perl Programming Language)

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (16)
As of 2014-09-30 17:19 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (378 votes), past polls