Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask

Re^4: shift in list context buggy?

by morgon (Curate)
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?

Replies are listed 'Best First'.
Re^5: shift in list context buggy?
by Athanasius (Chancellor) 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 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
Re^5: shift in list context buggy?
by LanX (Bishop) 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)

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1061848]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (5)
As of 2018-04-19 23:16 GMT
Find Nodes?
    Voting Booth?