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

Drop AutoHashEquals dependency, other minor updates #45

Merged
merged 2 commits into from
Dec 20, 2018

Conversation

christopher-dG
Copy link
Member

I don't precisely remember why we needed AutoHashEquals (I think maybe Julia v0.x didn't implement hash, which Dict keys require, for new structs), but one test did still depend on it. Regardless, it's not needed anymore.

Other changes:

  • Make struct fields concrete (mostly AbstractString -> String)
  • Replace some big interpolated expressions with the varargs form of print

@omus
Copy link
Contributor

omus commented Dec 20, 2018

If your fields of your custom types don't use concrete types then you may need to change how hashing works. On Julia 1.0.3:

julia> using AutoHashEquals

julia> struct Foo1
           x::AbstractString
       end

julia> hash(Foo1("A")) == hash(Foo1(SubString("A")))
false

julia> @auto_hash_equals struct Foo2
           x::AbstractString
       end

julia> hash(Foo2("A")) == hash(Foo2(SubString("A")))
true

julia> struct Foo3
           x::String
       end

julia> hash(Foo3("A")) == hash(Foo3(SubString("A")))
true

@christopher-dG
Copy link
Member Author

Maybe I'm missing something, but I think that that's ultimately okay, since the keys of Template.plugins are the plugin types rather than values.
Which would imply that AutoHashEquals was never actually required... I might have just gotten the idea that I needed when I wrote tests along the lines of Set(values(t.plugins)) == Set([...]).

@omus
Copy link
Contributor

omus commented Dec 20, 2018

I think you're safe to remove this now. I do think it's only safe to be removed because you also switched AbstractString -> String

Copy link
Contributor

@omus omus left a comment

Choose a reason for hiding this comment

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

I think I prefer the string interpolation but this is fine too

@christopher-dG
Copy link
Member Author

I find it a lot easier to edit the parts of the string when a) it's properly syntax highlighted and b) there are less parens to deal with

@christopher-dG christopher-dG merged commit a9cb7df into master Dec 20, 2018
@ararslan ararslan deleted the cdg/drop-ahe branch December 20, 2018 21:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants