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
Set operators unfriendly to mutable types #6632
Comments
From @zoffixznetSet operators are a lot less useful with mutable types, like SetHash, because my $days = SetHash.new: Date.today … Date.new: '2014-04-02'; |
From @smlsOn Mon, 23 Oct 2017 05:23:55 -0700, cpan@zoffix.com wrote:
I don't think setty operators always returning Set, is that different from listy operators/methods (Z, grep, map...) always returning Seq. For example, when you write: @foo .= grep: * %% 2; Then the grep returns a Seq, and and its the assignment to the Array variable which makes sure that in the end you'll have the results as an Array. (Still the same Array, in fact, just with new contents.) If you were to use a Scalar variable, you would get essentially the same issue as in your quoted Set example: $foo .= grep: * %% 2; # Oops, $foo is now an immutable Seq. The "solution", IMO, would not be to make your quoted example work (by adding further special cases to the return types of the setty operators or otherwise), but rather to make the following variation of it work: my %days is SetHash = Date.today … Date.new: '2014-04-02'; %days ∖= %days.grep: *.key.day-of-week > 5; %days{Date.today}:delete; ...and then promote %-sigiled SetHash variables as the recommended way to store SetHash'es. It should be possible to make this last example work by implementing `method STORE` for type SetHash, right? (That it currently doesn't, may well be an oversight rather than a design choice.) |
The RT System itself - Status changed from 'new' to 'open' |
From @zoffixznetOn Mon, 23 Oct 2017 09:12:58 -0700, smls75@gmail.com wrote:
Thanks for clarifying. Yeah, it looks better if it had a % sigil on it too. Gonna reject this issue and open a new one on our GitHub tracker[^1] to take it for a spin |
From @zoffixznetRejecting 'cause it's a misunderstanding of how things work in OP. Opened the suggestion for making `%` sigil work in rakudo/rakudo#1203 |
@zoffixznet - Status changed from 'open' to 'rejected' |
From @lizmat
Commit b6a4d5b555520451c5c8a made this possible: my %d is SetHash = Date.today .. Date.new("2017-11-30”);
|
From @AlexDanielDoes it mean that this now needs tests? On 2017-10-30 06:42:25, elizabeth wrote:
|
@AlexDaniel - Status changed from 'rejected' to 'open' |
From @lizmatHmmm…. I guess this one does… good point! :-)
|
From @zoffixznetI see tests already exists for this ticket in S02-types/sethash.t |
@zoffixznet - Status changed from 'open' to 'resolved' |
Migrated from rt.perl.org#132352 (status was 'resolved')
Searchable as RT132352$
The text was updated successfully, but these errors were encountered: