That said, it seems blindingly obvious that return @this returns an array!
Is it blindly obvious--really? Would you also say that return &foo obviously returns a subroutine?
return @array doesn't return an array any more than return &foo returns a subroutine. The key is that return EXPR doesn't make the subroutine/eval/do FILE return the expression itself, but rather the evaluation of the expression, which may depend on the context in which the subroutine/eval/do FILE is evaluated.
But would we say that an array is a list or a scalar?
You're focusing on what an array is in different contexts. An array is an array. If you focus on what an array evaluates to you'll get more to the point. Every evaluation is in a context, and an array evaluates differently in list versus scalar context just as a subroutine (may) do. perldata says (my emphasis)
Note that the value of an actual array in scalar context is the length of the arrayi.e., it evaluates to the length.
lodin
In reply to Re^5: Evil Interview Questions (memes) (return @foo VS return &foo)
by lodin
in thread Evil Interview Questions
by kyle
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |