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

some Enum improvements #30924

Merged
merged 1 commit into from
Feb 15, 2019
Merged

some Enum improvements #30924

merged 1 commit into from
Feb 15, 2019

Conversation

JeffBezanson
Copy link
Member

@JeffBezanson JeffBezanson commented Jan 31, 2019

  • define fewer methods per type
    isless and printing methods can be defined once for all Enums.

  • normalize print and show methods

    • print, string, Symbol just give the name (as before)
    • show shows the name, prefixed with its defining module based on compactness and visibility, like how types are displayed
    • show for text/plain shows the longer name::type = value output
  • check for duplicate names
    We checked for duplicate values, but not names. I assume that was an oversight?

@JeffBezanson JeffBezanson added the minor change Marginal behavior change acceptable for a minor release label Jan 31, 2019
base/Enums.jl Outdated
namemap[i] = s
push!(values, i)
if s in seen
throw(ArgumentError("names for Enum $typename are not unique"))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we include the duplicated name in the error message for user convenience, since we know at this point that it's s?

@JeffBezanson JeffBezanson force-pushed the jb/enumupdate branch 2 times, most recently from 533ad7c to 4f20efe Compare February 4, 2019 18:17
@JeffBezanson JeffBezanson added display and printing Aesthetics and correctness of printed representations of objects. triage This should be discussed on a triage call labels Feb 5, 2019
- define fewer methods per type
- normalize print and show methods
- check for duplicate names
@JeffBezanson JeffBezanson removed the triage This should be discussed on a triage call label Feb 15, 2019
@JeffBezanson JeffBezanson merged commit e62b492 into master Feb 15, 2019
@JeffBezanson JeffBezanson deleted the jb/enumupdate branch February 15, 2019 17:59
jmert added a commit to jmert/BitFlags.jl that referenced this pull request Mar 10, 2019
jmert added a commit to jmert/BitFlags.jl that referenced this pull request Mar 10, 2019
jmert added a commit to jmert/BitFlags.jl that referenced this pull request Apr 17, 2020
Duplicates the improvement made to Base's Enums: JuliaLang/julia#30924
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
display and printing Aesthetics and correctness of printed representations of objects. minor change Marginal behavior change acceptable for a minor release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants