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 weird constructors #3261

Merged
merged 2 commits into from
Nov 28, 2022
Merged

Conversation

barucden
Copy link
Contributor

Resolves #3215

The individual commits are standalone, one addresses APIOptions and the other PackageToken, so they don't have to be squashed.

@fredrikekre
Copy link
Member

I think it would be nicer not to introduce all the new types, instead just use a function api_options or w/e that return the dictionary.

@barucden barucden force-pushed the remove-dict-ctor branch 3 times, most recently from 1b0e16e to bf7163e Compare November 21, 2022 09:28
@barucden
Copy link
Contributor Author

I did as suggested.

@barucden
Copy link
Contributor Author

The failed test is due to a network error during a git clone.

@barucden
Copy link
Contributor Author

What do you think, @fredrikekre? Is it ready for merge?

(cc @KristofferC, who reported the issue)

@KristofferC
Copy link
Member

Yep looks good, thank you!

@KristofferC
Copy link
Member

Actually, could the PackageToken still be a union?

@barucden
Copy link
Contributor Author

Actually, could the PackageToken still be a union?

I believe so. It just appeared to me like the perfect use-case for an abstract type with several subtypes. It seemed cleaner to me.

Is there a particular reason for Union?

@KristofferC
Copy link
Member

Is there a particular reason for Union?

When there are only a few "subtypes" it means the compiler can branch on the different unions. If it is an abstract type the compiler doesn't know anything. It might not matter a lot here but there has been some issues earlier with "invalidations" (a bit of a technical thing) when Pkg has some type unstable code. To prevent that, I think maybe we should just put back the union so that things are the way they used to be.

@barucden
Copy link
Contributor Author

I was not aware of that; thanks for the explanation. PackageToken is a Union now.

I still left PackageIdentifier as a struct, not just an alias for a String. I hope I don't miss another technical reason why it was a good idea to have it as an alias :)

`APIOptions` is defined as an alias for `Dict{Symbol, Any}`.
Consequently, the definition of a constructor for `APIOptions`
introduced a new constructor for Dict. This commit removes that
constructor.
`PackageToken` is a Union of multiple struct types. This commit removes
a constructor for `PackageToken` and replaces it with a function
`packagetoken`.

Furthermore, this commit removes `PackageIdentifier` as an alias for
String and replaces that with a struct type, which wraps a String
containing a package identifier.
@KristofferC KristofferC merged commit d5ac7ca into JuliaLang:master Nov 28, 2022
@barucden barucden deleted the remove-dict-ctor branch November 28, 2022 14:39
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.

Weird constructor for type alised Dict
3 participants