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

Static arity tests? #28

Open
Lupus opened this issue Dec 12, 2019 · 2 comments
Open

Static arity tests? #28

Lupus opened this issue Dec 12, 2019 · 2 comments

Comments

@Lupus
Copy link
Contributor

Lupus commented Dec 12, 2019

For backends like Golang arity tests in runtime are going to be troublesome to implement, and are very likely to be inefficient.

I wonder if it's possible to statically check if we're currying, or it's time to actually call something?

@jordwalke
Copy link
Owner

I committed to a branch that exposes arity for exports so that it can later be used to optimize compilation and avoid call1/call2 functions in many cases. However, it should just be an optimization, and so it should be possible to always be able to use call2/call3 as a fallback, even if slower. As long as go has a fallback that is slower, this is a viable path. If it doesn't have a fallback (or if other languages do not) then the solution is to make lambdas be emitted with their arity tagged.

var myFunc = [
  3,
  function(a, b, c) { return a + b + c; }
];

@Lupus
Copy link
Contributor Author

Lupus commented Dec 18, 2019

In Golang functions are first class, it supports creating closures, and passing them as values, but Golang is statically typed, so this tagged lambda needs to be specialized for types of parameters, and declared somewhere on top...

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