in reply to Re: Timing of Array-Size Determination Methods
in thread Timing of Array-Size Determination Methods

I quote perldoc -f scalar:
Because "scalar" is unary operator
So no it's not a function call at all, even if looks like one. (Just like split.)
$ perl -MO=Terse -e'scalar @_' LISTOP (0x8133508) leave [1] OP (0x8133370) enter COP (0x8133400) nextstate UNOP (0x81333c0) scalar UNOP (0x8133630) rv2av [1] SVOP (0x8133540) gv GV (0x8124334) *_ -e syntax OK $ perl -MO=Terse -e'$#_+1' LISTOP (0x8133440) leave [1] OP (0x8128040) enter COP (0x8133400) nextstate BINOP (0x8133508) add [2] UNOP (0x81333c0) av2arylen UNOP (0x8133630) rv2av [1] SVOP (0x8133540) gv GV (0x8124334) *_ SVOP (0x8133370) const IV (0x8132bdc) 1 -e syntax OK
Certainly looks like $#arr + 1 loses that argument as well. Not that it mattered in the first place..

Makeshifts last the longest.

  • Comment on Re^2: Timing of Array-Size Determination Methods (scalar() != function)
  • Download Code

Replies are listed 'Best First'.
Re: Re^2: Timing of Array-Size Determination Methods (scalar() != function)
by Juerd (Abbot) on Jun 03, 2003 at 05:32 UTC

    All functions in perlfunc are in fact operators, I think. I believe the term "unary operator" is also used for ($)-prototyped functions, like how "list operator" is for (@)-prototyped (or prototypeless) functions.

    Juerd # { site => 'juerd.nl', plp_site => 'plp.juerd.nl', do_not_use => 'spamtrap' }

      Some further optree inspection suggests you are right; point taken. The point that, for those who care, scalar @_ compiles to 3 fewer ops than $#_ + 1 still stands though.

      Makeshifts last the longest.