-
Notifications
You must be signed in to change notification settings - Fork 46
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
Implement objects to represent YAML versions #223
Comments
Which is better? abstract type YAMLVersion end
struct YAMLV1_1 <: YAMLVersion end
struct YAMLV1_2 <: YAMLVersion end
forwardchars!(::YAMLV1_1, stream::TokenStream, n::Integer=1) #... struct YAMLVersion{T} end
const YAMLV1_1 = YAMLVersion{:Version1_1}()
const YAMLV1_2 = YAMLVersion{:Version1_2}()
forwardchars!(::YAMLV1_1, stream::TokenStream, n::Integer=1) #... |
I'm clearly finding the PR and the issue in the wrong order here. As I see it the biggest difference is that
vs
whereas definitions become
vs
Functionally it shouldn't make a difference so I'd vote for the first being better on the grounds that the calls and definitions are more uniform, plus having to write and read the long form of the second in definitions seems worse. |
The fact that you won't get a compiler error from misspelling
is also an argument in favor of the first option. |
Year, the latter should be struct YAMLVersion{T} end
const YAMLV1_1 = YAMLVersion{:Version1_1}()
const YAMLV1_2 = YAMLVersion{:Version1_2}()
# definition
forwardchars!(::YAMLVersion{:Version1_1}, stream::TokenStream, n::Integer=1) #...
# call
forwardchars!(YAMLV1_1, stream) We can see this for example in Julia Base's |
I have asked this in Discourse: Which is better for traits? Subtyping vs parametric typing |
I believe |
I asked this also in Julia Slack's internal channel. Simon Byrne said
So there seems to be no specific reason to that implementation. |
Let's use abstract type & subtyping pattern. |
#198 (comment)_
The text was updated successfully, but these errors were encountered: