-
Notifications
You must be signed in to change notification settings - Fork 9
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
InstanceOf operator #95
Comments
I am fine with this, if someone (@jeromesimeon?) is interested in implementing it. In practice, note that this complicates things like extraction and (de)serialization and such. I believe this is the first operator/language feature that embeds a type, other then tDNNRC. It will also require that operators be parameterized over a foreign type and a brand relation (since these are both needed in order to construct an rtype). This will ripple changes throughout the code for languages, the compiler frontend modules, ocaml... Note that you will need to implement this type test in the runtimes for our current backends (java, javascript). I assume that the instanceof operator returns an either, similar to the branding casting operator. In the success branch it will provide the given data, but with an enriched type (since we don't have flow-sensitive typing, returning a boolean is not nearly as useful). Also, it would be nice to add optimizations for this (although that could become a separate issue). |
Thanks for all the feedback. Quite a bit more work than I naively thought. I'll keep it in mind, and may sign up for it at some point. |
Wouldn't it be nice to have an instance of operator (for a given statically known type)?
Something that might look like
d instanceof t
If I'm correct, this could be implemented as:
t'
of datad
(for a given normalized data) -- see inTDataInfer
t'
is a subtype oft
-- see inRSubtype
I believe this is a sound procedure thanks to the lovely theorem in
TDataInfer
:Theorem infer_data_type_least {d τ₁ τ₂} : infer_data_type d = Some τ₁ -> d ▹τ₂ -> τ₁ <: τ₂.
The text was updated successfully, but these errors were encountered: