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
Sending named parameter ;p with value 0 to .postfix:<{ }> should yield the value and not the pair in Rakudo #3129
Comments
From @masak<lizmat> rn: my %h= (:a<1>); say %h.postcircumfix:<{ }>("a", p => 0 ) Usually, just accessing a hash yields "1" in the above case. The :p |
From @masak<lizmat> actually, the :p(0) also applies to :delete and :exists |
@masak - Status changed from 'new' to 'open' |
From @usev6There have been some relevant changes since this ticket was created: 1 postcircumfix:<{ }> is a sub now. 2 There was a change to the design documents and according to S02 the adverbial forms :p, :kv, :k, :v "weed out non-existing entries if the adverb is true; if not, they leave them in, just as an ordinary slice would" (cmp. Raku/old-design-docs@fd94c28225). Taking these changes into account, now the mentioned commands run as expected. First the :p(0) stuff: $ perl6 -e 'my %h; %h<a>=1; say %h<a>:p' $ perl6 -e 'my %h; %h<a>=1; say %h<a>:p(0)' ## same result since key "a" exists $ perl6 -e 'my %h; %h<a>=1; say %h<a>:!p' ## same thing $ perl6 -e 'my %h; %h<a>=1; say %h<b>:p' ## key "b" does not exist $ perl6 -e 'my %h; %h<a>=1; say %h<b>:p(0)' ## pair not weeded out $ perl6 -e 'my %h; %h<a>=1; say %h<b>:!p' ## same thing The adverbs :delete and :exists also work as designed: $ perl6 -e 'my %h; %h<a>=1; say %h<a>:delete; say %h' $ perl6 -e 'my %h; %h<a>=1; say %h<a>:delete(0); say %h' $ perl6 -e 'my %h; %h<a>=1; say %h<a>:exists' $ perl6 -e 'my %h; %h<a>=1; say %h<a>:exists(0)' For :p(0) I added tests to S32-hash/pairs.t with commit Raku/roast@a543b07ab4 For :delete(0) and :exists(0) there are passing tests in S32-hash/delete-adverb.t and S32-exists-adverb.t, respectively. I'm closing this ticket now. |
1 similar comment
From @usev6There have been some relevant changes since this ticket was created: 1 postcircumfix:<{ }> is a sub now. 2 There was a change to the design documents and according to S02 the adverbial forms :p, :kv, :k, :v "weed out non-existing entries if the adverb is true; if not, they leave them in, just as an ordinary slice would" (cmp. Raku/old-design-docs@fd94c28225). Taking these changes into account, now the mentioned commands run as expected. First the :p(0) stuff: $ perl6 -e 'my %h; %h<a>=1; say %h<a>:p' $ perl6 -e 'my %h; %h<a>=1; say %h<a>:p(0)' ## same result since key "a" exists $ perl6 -e 'my %h; %h<a>=1; say %h<a>:!p' ## same thing $ perl6 -e 'my %h; %h<a>=1; say %h<b>:p' ## key "b" does not exist $ perl6 -e 'my %h; %h<a>=1; say %h<b>:p(0)' ## pair not weeded out $ perl6 -e 'my %h; %h<a>=1; say %h<b>:!p' ## same thing The adverbs :delete and :exists also work as designed: $ perl6 -e 'my %h; %h<a>=1; say %h<a>:delete; say %h' $ perl6 -e 'my %h; %h<a>=1; say %h<a>:delete(0); say %h' $ perl6 -e 'my %h; %h<a>=1; say %h<a>:exists' $ perl6 -e 'my %h; %h<a>=1; say %h<a>:exists(0)' For :p(0) I added tests to S32-hash/pairs.t with commit Raku/roast@a543b07ab4 For :delete(0) and :exists(0) there are passing tests in S32-hash/delete-adverb.t and S32-exists-adverb.t, respectively. I'm closing this ticket now. |
@usev6 - Status changed from 'open' to 'resolved' |
Migrated from rt.perl.org#117935 (status was 'resolved')
Searchable as RT117935$
The text was updated successfully, but these errors were encountered: