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

Remove Base.convert methods between AbstractString and Kind #500

Merged
merged 3 commits into from
Oct 6, 2024

Conversation

fredrikekre
Copy link
Member

No description provided.

fredrikekre and others added 3 commits September 3, 2024 23:19
This patch removes the method `convert(::Type{String}, ::Kind)` used for
converting kinds to strings and replaces it with the already existing
method of `Base.string`. There are two reason for this: i) the method
causes invalidations when loading the package and ii) `convert` is
called implicitly in e.g. constructors and should therefore typically
only be defined between similar enough types.
This patch removes the method `Base.convert(::Type{Kind}, ::AbstractString)`
and replaces it with a `Kind(::AbstractString)` constructor. The reason
for this is that `convert` is called implicitly in e.g. constructors and
should therefore typically only be defined between similar enough types.
@LilithHafner
Copy link
Member

This seems worth doing to me. converting between Kind and String is too permissive

julia> push!(["a"], K"=")
2-element Vector{String}:
 "a"
 "="

Copy link
Member

@c42f c42f left a comment

Choose a reason for hiding this comment

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

This seems great, thanks :)

@c42f
Copy link
Member

c42f commented Oct 6, 2024

For context, convert() was overridden because the implementation of Kind was originally inspired by Base.@enum.

@LilithHafner
Copy link
Member

Is squash merge okay?

@fredrikekre fredrikekre merged commit 9483de8 into main Oct 6, 2024
36 checks passed
@fredrikekre fredrikekre deleted the fe/convert branch October 6, 2024 11:22
@c42f
Copy link
Member

c42f commented Oct 7, 2024

I generally prefer squash merge and I think it's a good default.

Some exceptions where an actual merge commit can be worthwhile:

  • The feature branch has several carefully distinguished changes in their own patches such that keeping them separate makes the history easier to understand.
  • The change was authored by multiple people in distinct patches
  • The merge has nontrivial conflicts with the base branch to the extent that rebasing is very hard and error prone (a very unusual circumstance which mainly happens when multiple large, long lived feature branches interfere. To be avoided! Unlikely to happen in this library.)

@fredrikekre
Copy link
Member Author

For context, convert() was overridden because the implementation of Kind was originally inspired by Base.@enum.

Enums doesn't have any converts like this either though?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants