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

Add Support for Existential Types for Managing Generic Declarations #81

Open
pauljoo28 opened this issue Apr 3, 2020 · 1 comment
Open
Labels
enhancement New feature or request

Comments

@pauljoo28
Copy link
Collaborator

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.

@Checkmate50
Copy link
Contributor

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 Checkmate50 changed the title Add Support for Type Inferencing for Declare Statements Add Support for Existential Types for Managing Generic Declarations Apr 3, 2020
@Checkmate50 Checkmate50 added the enhancement New feature or request label Apr 3, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants