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

What's the usage of AsDomain? Seems like DomainRef suffices #2

Closed
dlfivefifty opened this issue Nov 22, 2023 · 4 comments
Closed

What's the usage of AsDomain? Seems like DomainRef suffices #2

dlfivefifty opened this issue Nov 22, 2023 · 4 comments

Comments

@dlfivefifty
Copy link
Member

abstract type AsDomain end

@daanhb
Copy link
Member

daanhb commented Nov 22, 2023

I had modelled this after Ref in julia. Ref(5) is also not a concrete type and returns something else:

julia> Ref(5)
Base.RefValue{Int64}(5)

My thinking here was that some objects need not be modified when passed as a domain, for example AsDomain(d::Domain) = d. But since DomainRef is a concrete type, one would expect it to return an instance of DomainRef.

@dlfivefifty
Copy link
Member Author

But a Domain is not a subtype of AsDomain so AsDomain(d::Domain) = d is bad style (type constructors should always return an instance of that type)

@daanhb
Copy link
Member

daanhb commented Nov 22, 2023

That's true. I guess AsDomain could just be a function, instead of an abstract type, but then we have more names in total since the user writes foo(AsDomain(d)) and the developer writes foo(d::DomainRef) = .... We could simply use DomainRef, but in that case regular domains would have to be wrapped as well. If that's not too bad, it would admittedly be simpler.

I originally thought that AsDomain(d) might also return something else that acts like the domain which d is supposed to represent, but thinking about it now that conflates things. There already is a mechanism to convert to a domain.

Only thing left on my mind is why Ref is not a concrete type.

@daanhb
Copy link
Member

daanhb commented Nov 22, 2023

I've removed AsDomain and just use DomainRef now. It is simpler.

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

No branches or pull requests

2 participants