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

Move binary and unary operators to external functions #635

Open
bvssvni opened this issue Sep 14, 2019 · 6 comments
Open

Move binary and unary operators to external functions #635

bvssvni opened this issue Sep 14, 2019 · 6 comments

Comments

@bvssvni
Copy link
Member

bvssvni commented Sep 14, 2019

Instead of treating binary and unary operators as special, they can be turned into external functions. This will simplify the runtime quite a bit.

@bvssvni
Copy link
Member Author

bvssvni commented Sep 14, 2019

One problem is that when overriding external functions, the type checker makes wrong assumptions.

@bvssvni
Copy link
Member Author

bvssvni commented Sep 14, 2019

The runtime type is not guaranteed, so it might be acceptable to just let the type checker make wrong assumptions and get errors at runtime when something is wrong.

@bvssvni
Copy link
Member Author

bvssvni commented Sep 14, 2019

Another solution is to make a type error if one declares a function with same name and incompatible type as the one assumed by the type checker.

@bvssvni
Copy link
Member Author

bvssvni commented Sep 14, 2019

Another solution is to add smarter type inference such that the type checker can handle all the cases where the output type depends on the type of the input.

@bvssvni
Copy link
Member Author

bvssvni commented Sep 17, 2019

One problem is that && and || are lazy, which means they do not always evaluate the right argument.

@bvssvni
Copy link
Member Author

bvssvni commented Sep 17, 2019

A solution to the lazy problem is to add support for making external functions lazy, e.g. by specifying a default value to return, if the argument is evaluated to that value. This requires lazy functions to return same type as the argument which has a default value.

@bvssvni bvssvni changed the title Make binary and unary operators into external functions Move binary and unary operators to external functions Oct 3, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant