On Thu, Jul 22, 2004 at 11:12:16PM +0100, Dave Mitchell wrote:
: On Wed, Jul 21, 2004 at 04:37:29PM -0700, Larry Wall wrote:
: > We allowed/required @foo to interpolate in Perl 5, and it catches a
: > certain number of people off guard regularly, including yours truly.
: > So I can argue [EMAIL PROTECTED] both ways.
: 
: Currently @foo[] is a syntax error. maybe "@foo[]" in Perl6 could be
: what "@foo" is in Perl5? And I mean a literal '[]', not
: "@foo[expression-that-returns-an-empty-list]"

Well, I can argue that one both ways too.  It's certainly recognizable
as some kind of undifferentiated subscript, but it has two distinct
interpretations, unfortunately.  The "null list" inside could either
be considered to be a zero-dimensional subscript, or a one-dimensional
subscript that happens to be a null slice.

If you take the former interpretation, it makes sense that @foo[]
means the whole array as the limiting case:

    @foo[3;2;1], @foo[3;2], @foo[3], @foo[]

If you take the latter, it makes sense that @foo[] means none of
the array:

    @foo[1,2,3], @foo[1,2], @foo[1], @foo[]

A code generator could come up with either of those as a limiting case
and reasonably expect either everything or nothing.  What the user
expects will probably depend also on the declared dimensionality of
the object.  (Similar considerations apply to "%foo{}".)  So we have to
penalize one syntax or the other.  Either we force the user to say
something like

    @foo[*]

to indicate that the first subscript is to be considered a "Zen"
slice ("make me one with everything") or we force them to say

    @foo[()]

to indicate that the first subscript is to be considered an empty
slice.  You just can't have it both ways.  Certainly there seems
to be a lot more utility in arrays with everything in them rather
than nothing, so I'm inclined to bias it in favor of @foo[] returning
the entire array, especially if we go with the end bracket rule.

Larry

Reply via email to