-
Notifications
You must be signed in to change notification settings - Fork 28
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
Should issettable
be allowed to be defined on a type?
#76
Comments
I guess this was a bit of an experiment in a value-driven interface. Traits functions that take values and return values. Also, it's theoretically possible to have types that are "freezable" at run-time, for example. We could use The only place I use seem to need to use type-domain logic is in
Constant propagation seems to work everywhere I've checked. Have you had any issues? I don't know - what are your thoughts? |
For context, copy-on-write indices would work well with indices and how |
Did you guys have any further thoughts? Are you aware of some good scenarios for defining and/or using it at the type level? |
Yeah, the main motivation for opening the issue was our joint work on a new Interfaces.jl package, which is focused on supporting static interfaces in Julia for now (and not in any dispatchable way, but more as a developer and documentation aid). But the "static" requirement means that for conditional requirements like |
While reviewing the interfaces here with @nickrobinson251, we found it curious that
issettable
is only expected to be defined on an instance instead of as a "trait" that can be defined on the type. From the docs, it says that if mutability is supported, thenissettable
should returntrue
, andsetindex!
should be defined. It seems like the majority of implementations would be able to defineissettable
statically on a type once, instead of on instances.One pattern we've followed in the Tables.jl interface for these kind of type traits is to allow defining the trait function on either instances or types, with the encouragement to define on the type where possible. But users/callers of the trait, should always call on the instance, while having a generic fallback like
issettable(x::T) where {T} = issettable(T)
. That allows the compiler to correctly statically infer traits where possible, and rely on runtime checking when necessary.Just curious how intentional the current
issettable
design was and if so, what the context is around the decision.The text was updated successfully, but these errors were encountered: