Skip Menu |
Report information
Id: 127789
Status: open
Priority: 0/
Queue: perl6

Owner: Nobody
Requestors: masak <cmasak [at] gmail.com>
Cc:
AdminCc:

Severity: (no value)
Tag: Bug
Platform: (no value)
Patch Status: (no value)
VM: (no value)



Date: Sat, 26 Mar 2016 14:44:03 +0100
To: rakudobug [...] perl.org
From: Carl Mäsak <cmasak [...] gmail.com>
Subject: [BUG] SumeEnum.enums.invert produces a hash where the values are string names, not enum values in Rakudo
Download (untitled) / with headers
text/plain 434b
<masak> m: enum Stone «:None<.> :Vertical<V> :Horizontal<H> :Neutral<n>»; my %h = Stone.enums.invert; say %h.perl <camelia> rakudo-moar 1d1256: OUTPUT«{"." => "None", :H("Horizontal"), :V("Vertical"), :n("Neutral")}␤» <masak> I haven't thought hard about this, but it would be more useful in this case to get the enum *values* in the hash values <masak> not their string names * masak submits rakudobug, just in case he's right
Subject: Re: [perl #127789] [BUG] SumeEnum.enums.invert produces a hash where the values are string names, not enum values in Rakudo
Date: Sat, 26 Mar 2016 20:59:09 +0100
From: Elizabeth Mattijsen <liz [...] dijkmat.nl>
To: "Carl Mäsak (via RT)" <perl6-bugs-followup [...] perl.org>
Download (untitled) / with headers
text/plain 1.1k
Show quoted text
> On 26 Mar 2016, at 14:44, Carl Mäsak (via RT) <perl6-bugs-followup@perl.org> wrote: > > # New Ticket Created by "Carl Mäsak" > # Please include the string: [perl #127789] > # in the subject line of all future correspondence about this issue. > # <URL: https://rt.perl.org/Ticket/Display.html?id=127789 > > > > <masak> m: enum Stone «:None<.> :Vertical<V> :Horizontal<H> > :Neutral<n>»; my %h = Stone.enums.invert; say %h.perl > <camelia> rakudo-moar 1d1256: OUTPUT«{"." => "None", :H("Horizontal"), > :V("Vertical"), :n("Neutral")}␤» > <masak> I haven't thought hard about this, but it would be more useful > in this case to get the enum *values* in the hash values > <masak> not their string names > * masak submits rakudobug, just in case he's right
I think the problem is really that .enums gives you a Hash with the string names as keys. The .invert then just does what it is supposed to do. So either we let enums return an object Hash with the Enums as keys (which will probably break code), or we need to return a Hash with a special .invert method mixed in. But then we would also need to think what .kv and .pairs would do on that hash. I think we’re on a slippery slope here… :( Liz


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

For issues related to this RT instance (aka "perlbug"), please contact perlbug-admin at perl.org