in reply to Re: @_ the default variable?
in thread @_ the default variable?

If shift "is not really a function", what is it? And I thought only *subroutines* were called with &. shift certainly isn't a subroutine.

Replies are listed 'Best First'.
Re: Re: Re: @_ the default variable?
by wog (Curate) on Sep 14, 2001 at 23:04 UTC
    The words subroutine and function are often used interchangably in perl. (Even perlsub does it!) What I meant by calling shift "not really a function" was that it is very unlike the functions you define in your code, which have a symbol table entry and thus are associated with a package, can have coderefs be taken of them, and be aliased to other names at the symbol table entry, or imported into other packages, in addition to being callable by the & syntax.
      You mean you can't override shift like you can with other built-in functions (import into CORE:: if memory serves)?
        Starting with perl version 5.6.1 you can override shift, like you can with other built-ins. As an indication of this prototype("CORE::shift") returns \@ (which seems a little odd considering the default argument... Hmm...)