On Sun May 03 13:24:39 2009, masak wrote:
> <moritz_> rakudo: say (hash(a => '3' )).perl
> <p6eval> rakudo cddb16: OUTPUT«{}»
> <moritz_> wait a sec
> <moritz_> let me look up the semantics of hash() first
> <masak> sure.
> <moritz_> If you wish to be less ambiguous, the C<hash> list operator
> will
> <moritz_> explicitly evaluate a list and compose a hash of the
> returned value,
> <moritz_> (from S04)
> <moritz_> S04:1187
> * masak submits rakudobug
This has come up before in the context of the list() function, but I
don't think it was ever resolved, and hash() will seem to want a similar
resolution.
In particular, while we might expect list(1,2,x=>3,4) to give us a
list of three elements, syntactically the above has only three
positional arguments and a named argument 'x'. It's not clear how
list() should function in that case.
With hash() it might be a bit easier -- we simply use all of the named
arguments as part of constructing the hash. But ordering becomes a bit
of an issue -- what to do with...?
hash('x' => 3, 'x', 4)
Does the resulting entry for 'x' become [3, 4] or [4, 3]? Or do we need
to know the relative ordering of the named/positional arguments (as in
list() above)?
At any rate, the spec seems to want a slight clarification here.
Thanks,
Pm