in reply to Re: Empty List miracle(1)
in thread Empty List miracle(1)

... the default behaviour of a list is scalar context is to return its last element...

... depending on associativity and precedence and arity and the presence of any prototypes in the surrounding expression which may change any of the former, so the choice of the word "default" is, at best, misleading.

Replies are listed 'Best First'.
Re^3: Empty List miracle(1)
by moritz (Cardinal) on Apr 30, 2010 at 06:28 UTC
    So what would be a better phrasing, in your opinion?
    Perl 6 - links to (nearly) everything that is Perl 6.

      I don't think there is a good way to explain the default behavior of a list in scalar context, because there are too many ways to create lists in Perl and too many ways to enforce scalar context.

      What does a list do in scalar context provided by scalar assignment?

      What does a list do in scalar context provided by the scalar operator?

      What does a list do in scalar context provided by any other infix operator?

      What does a list do in scalar context provided by the prototype of an operator?

      I might be missing some (hash key?).

        "List" Is a Four-Letter Word Note: there is no such thing as a list in scalar context. When this appears to be the case, the comma operator is put to work.