You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Fortunately, the syntax here can be fixed (see #80). There's a deeper issue, however, which is why I've renamed this issue: the need for existential types!
Right now, we have to write, say, with vec2 T: declare float dot(T x, T y) for all of vec2, vec3, vec4, which is a pain to write and maintain. The old Linguine vec type would be nice to have again, but we need to support existential types; think of OCaml-style types and match statements. For example, then, we could write something like:
type vec is
| vec2
| vec3
| vec4
with vec T:
T addone(T x) {
// OCaml-style syntax; I'm open to trying other syntax!
match T with:
| vec2 -> x + [1., 1.];
| vec3 -> x + [1., 1., 1.];
| vec4 -> x + [1., 1., 1., 1.];
}
For simplicity, we probably just want the possible resolution types to be explicit, as opposed to OCaml's more complex tuple type structure. There might be a better solution for this problem, but that's my suggestion and proposed solution -- let me know if you think of something better!
Checkmate50
changed the title
Add Support for Type Inferencing for Declare Statements
Add Support for Existential Types for Managing Generic Declarations
Apr 3, 2020
We currently do not support type inferencing for declare statements. The following does not parse:
declare float dot<t extends vec>(t x, t y);
.This is an issue in
test-u/generics/tagw_tdeclare_inference.lgl
.The text was updated successfully, but these errors were encountered: