in reply to Re^2: Reference of constants and literals
in thread Reference of constants and literals

Thats a matter of interpretation, the behaviour of push @arr, "elem" can be reproduce with prototypes sub name (\@@)

The prototype is just syntactic sugar for taking a reference (plus extra behaviour, for example enforcing list context), so independently of what it looks like on the caller side, the callee always sees a reference, never the array itself.

Replies are listed 'Best First'.
Re^4: Reference of constants and literals
by LanX (Saint) on Nov 24, 2008 at 11:28 UTC
    prototypes are not only syntactic sugar, they are essential to syntax
    print prototype 'CORE::push'; # \@@

    Cheers Rolf

      Saying a feature is essential to syntax doesn't prove it's not syntactic sugar. If anything, it proves that it is.

      If a feature is syntactic sugar, it means the feature adds an alternate syntax rather than adding functionality.

      Since
      sub foo(\@@); foo(@a, 'x');
      and
      sub foo; foo(\@a, 'x');
      are equivalent, prototypes are syntactic sugar.

        let's get back to the roots:

        > > You never pass an array or hash, just references to them. It's not even possible to pass arrays or hashes to subroutines.

        > Thats a matter of interpretation,

        The closest you can get to "passing an array" in perl is to pass the arr_ref. Thats my interpretation of passing, (and not only mine)

        So what do you mean with "It's not even possible to pass arrays or hashes to subroutines." What else could be considered passing an array, which is not possible in perl???

        Cheers Rolf