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

Spec: dynamic dispatch #23

Open
eudoxia0 opened this issue Apr 14, 2022 · 3 comments
Open

Spec: dynamic dispatch #23

eudoxia0 opened this issue Apr 14, 2022 · 3 comments
Assignees

Comments

@eudoxia0
Copy link
Member

eudoxia0 commented Apr 14, 2022

Closures, or some light OOP.

@miniBill
Copy link
Contributor

Does it make sense to have a FunctionN type class (with N from 0 to, say, 8) with a call(arg0,..., argN) method, and have the closure be compiled to a struct of the closed over variables? So a lambda would be linear iff it uses linear variables.

Main issue I can see is that iirc this requires actual type inference

@eudoxia0
Copy link
Member Author

So, my (very brief and compressed) thoughts on this:

Typeclasses do static dispatch. In a sense that's "all you need". But unless you want every type and function to be generic (with the associated compilation cost), you usually want a way to do dynamic dispatch. There's two ways to do this, broadly:

  1. Closures
  2. Lightweight OOP

I have some thoughts (which I hope I wrote down somewhere) on how to do this while preserving the soundness of the linear type system. It is possible. I just haven't worked on implementing this yet, because I think having a usable/practical stdlib and basic tooling is more valuable than this feature at present.

@miniBill
Copy link
Contributor

Functional approaches will always get my vote, so Closures over OOP 😆

But yeah, this doesn't seem to be a priority right now 🙂

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