New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Zen slice on hashes: is %h{} the same as %h{*} or not? #51
Comments
Simply replacing hash with array there gives "The empty |
|
On Jun 12, 2013, at 4:31 PM, Brian Gernhardt notifications@github.com wrote:
On the other hand: @A[] could be seen as returning all .values of an array, and so could %h{}. Liz |
I think this issue can be closed now. lizmat? |
|
Still thinks it could use some more explanation at S03:5161, but I can't think of any right now. So closing. |
The zen slice on hashes is currently implemented as:
multi method postcircumfix:<{ }>() { self }
I think it should be implemented as:
multi method postcircumfix:<{ }>() { self.values }
to make it inline with %hash{*}. This would make it consistent with the zen slice of arrays.
And it would make it inline with S03:5161, which states: "The empty C<[]> and C<.[]> postfix operators are interpreted as a zero-dimensional subscript returning the entire array, not as a one-dimensional null slice returning no elements. Likewise for C<{}> and C<.{}> on hashes, as well as the C<< <> >>, C<< .<> >>, C<«»>, and C<.«»> constant and interpolating slice subscripting forms."
So I ran a spectest with %h{} returning the values of the hash, just as %h{*}, and the following spectests failed:
t/spec/S02-literals/hash-interpolation.t (Wstat: 0 Tests: 10 Failed: 2)
Failed tests: 5-6
t/spec/S02-literals/misc-interpolation.t (Wstat: 0 Tests: 46 Failed: 1)
Failed test: 4
t/spec/S02-literals/quoting.rakudo (Wstat: 0 Tests: 162 Failed: 1)
Failed test: 124
t/spec/S02-types/hash.t (Wstat: 256 Tests: 22 Failed: 0)
Non-zero exit status: 1
Parse errors: Bad plan. You planned 81 tests but ran 22.
The last one because it was trying to do a sort on *.value, which of course doesn't work on Ints. So from a spec testing point of view, this would be easily fixed.
However, the general feeling on #perl6 was, that the current implementation was the Right Way To Do It. Hence this issue, as the feeling on #perl6 was that the spec should be adapted, rather than the implementation. Which, by the way, is done the same (wrong) way in Niecza.
The text was updated successfully, but these errors were encountered: