Skip to content
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

SumeEnum.enums.invert produces a hash where the values are string names, not enum values in Rakudo #5201

Open
p6rt opened this issue Mar 26, 2016 · 3 comments
Labels

Comments

@p6rt
Copy link

p6rt commented Mar 26, 2016

Migrated from rt.perl.org#127789 (status was 'open')

Searchable as RT127789$

@p6rt
Copy link
Author

p6rt commented Mar 26, 2016

From @masak

<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

@p6rt
Copy link
Author

p6rt commented Mar 26, 2016

From @lizmat

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-archive.perl.org/perl6/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

@p6rt
Copy link
Author

p6rt commented Mar 26, 2016

The RT System itself - Status changed from 'new' to 'open'

@p6rt p6rt added the Bug label Jan 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant