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

Re^4: shift in list context buggy?

by morgon (Deacon)
on Nov 09, 2013 at 18:41 UTC ( #1061848=note: print w/ replies, xml ) Need Help??


in reply to Re^3: shift in list context buggy?
in thread shift in list context buggy?

Just for curisosity - you write:

shift is one of those keywords...
The "sub"-perldoc uses similar vague language:
Many built-in functions may be overridden
Finally, some built-ins (e.g. "exists" or "grep") can't be overridden
Is there a list somewhere of the built-ins that can and those that cannot be overridden or is "many" and "some" all that's documented?


Comment on Re^4: shift in list context buggy?
Re^5: shift in list context buggy?
by Athanasius (Monsignor) on Nov 10, 2013 at 07:05 UTC

    The Camel Book (4th edition, p. 411) is similarly vague:

    Many built-in functions may be overridden, although (like knocking holes in your walls) you should do this only occasionally and for good reason.

    But this 2001 node by danger:

    Re: Overloading Perl's Built-In's

    has a list of non-overridable built-in functions, together with the claim that these functions may be identified as “the ones defined to return a negative value in toke.c in the perl source code.” Alas, with my almost-zero knowledge of said perl source code, I can’t find any correlation between the given list and the contents of toke.c. :-(

    Anyway, hope that helps,

    Athanasius <°(((><contra mundum Iustus alius egestas vitae, eros Piratica,

Re^5: shift in list context buggy?
by LanX (Canon) on Nov 10, 2013 at 07:16 UTC
    IIRC every built-in returning a valid prototype.

    Can't check ATM... Later more...

    Cheers Rolf

    ( addicted to the Perl Programming Language)

Re^5: shift in list context buggy?
by tobyink (Abbot) on Nov 10, 2013 at 09:13 UTC

    The first list in CORE gives you keywords that definitely cannot be overridden using use subs. I think perhaps that anything not listed there may be overridden, but I could be wrong.

    Generally the best way to find out if a particular function can be overridden is to try. And remember to test it on all the versions of Perl that you care about because this is something that has been changing quite a bit in recent releases - more and more keywords are becoming over-ridable.

    use Moops; class Cow :rw { has name => (default => 'Ermintrude') }; say Cow->new->name

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (9)
As of 2014-09-19 00:30 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

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











    Results (128 votes), past polls