Nicholas Clark wrote:
[...]
> And what happens if I write
>
>   %hash4 = ("Something", "mixing", pairs => and, "scalars");
                   1           2        3      4       5
Perl5 says "Odd number of elements in hash assignment at -e line 1."
And Perl6 should, too.

IMHO, your example isn't too good anyway. Something involving a pair at the
place where a Perl5-like behaviour would expect to set a value would be even
a bit more evil.

Let's use this example:
%h = ( 'a', pk => 'pv', 'b', 'c');

Other than that, some possible behaviours I could think of would be:

- If the list contains scalars, consider pairs as two scalars (bad).
Resulting hash (key=>value)
a => pk
pv => b
c => undef

- If the list contains pairs, assign the pairs, then do the Perl5-thing of
alternatingly assigning keys and values from the scalars.
a => b
pk => pv
c => undef

- Fatal error.

- Wherever a pair starts but a value is expected, add an undef.
a => undef
pk => pv
b => c

I think the latter would be most intuitive. Maybe.

Steffen
--
@n=(544290696690,305106661574,116357),$b=16,@c=' ,JPacehklnorstu'=~
/./g;for$n(@n){map{$h=int$n/$b**$_;$n-=$b**$_*$h;$c[@c]=$h}c(0..9);
push@p,map{$c[$_]}@c[c($b..$#c)];$#c=$b-1}print@p;sub'c{reverse @_}

Reply via email to