On Mon, Nov 24, 2008 at 7:19 AM, Rafael Garcia-Suarez <[EMAIL PROTECTED]> wrote: > Moritz Lenz wrote in perl.perl6.compiler : >> jerry gay wrote: >>> On Fri, Nov 21, 2008 at 10:43, via RT Moritz Lenz >>> <[EMAIL PROTECTED]> wrote: >>>> # New Ticket Created by Moritz Lenz >>>> # Please include the string: [perl #60732] >>>> # in the subject line of all future correspondence about this issue. >>>> # <URL: http://rt.perl.org/rt3/Ticket/Display.html?id=60732 > >>>> >>>> >>>> From #perl6 today: >>>> >>>> 19:33 < moritz_> rakudo: my $x = [ 42 ]; say $x<0> >>>> 19:33 < p6eval> rakudo 32984: OUTPUT[42] >>>> >>>> I don't think that should be allowed. >>>> >>> the real test is: >>> >>> (8:52:47 PM) [particle]1: rakudo: my $x = [42]; say $x<0_but_true>; >>> (8:52:49 PM) p6eval: rakudo 32998: OUTPUT[42] >>> (8:53:38 PM) [particle]1: rakudo: my $x = [42]; say $x<true_but_0>; >>> (8:53:40 PM) p6eval: rakudo 32998: OUTPUT[42] >>> (8:53:50 PM) [particle]1: rakudo: my $x = [42]; say $x<XXX>; >>> (8:53:52 PM) p6eval: rakudo 32998: OUTPUT[42] >>> (8:54:37 PM) [particle]1: rakudo: my $x = ['a', 42]; say $x<XXX>; >>> (8:54:39 PM) p6eval: rakudo 32998: OUTPUT[a] >>> (8:58:41 PM) [particle]1: rakudo: my $x = ['a', 42]; say $x<1.4>; >>> (8:58:44 PM) p6eval: rakudo 32998: OUTPUT[42] >>> (8:58:48 PM) [particle]1: rakudo: my $x = ['a', 42]; say $x<0.4>; >>> (8:58:50 PM) p6eval: rakudo 32998: OUTPUT[a] >>> >>> so, the index is coerced to an integer. is that really wrong? >>> ~jerry >> >> IMHO yes, because Perl explicitly distinguishes between arrays and >> hashes (and it's one of the things we never regretted, I think ;-). Any >> intermixing between the two would only lead to confusion, especially if >> somebody writes a class whose objects are both hashe and array. > > Yes, that leads to confusion. (And confusion leads to anger, and so on) > Which is why we removed pseudo-hashes from Perl 5.10.
Perl 6 explicitly _does_ allow hash-reference syntax, for the specific purpose of customized indices. That said, the sample code would not work, since you must explicitly define your custom index before you use it. Examples from the Synopses include a custom index that's based on the months of the year, so that you can say, e.g., @x<Jan> instead of @x[0]. -- Jonathan "Dataweaver" Lang