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

kernel.apl - alpaca core functions #184

Open
Licenser opened this issue Jun 14, 2017 · 3 comments
Open

kernel.apl - alpaca core functions #184

Licenser opened this issue Jun 14, 2017 · 3 comments

Comments

@Licenser
Copy link
Contributor

Licenser commented Jun 14, 2017

The thought is the following: let the compiler to the bare minimum work of bootstrapping the alpaca primitives and implement as much of the rest in alpaca itself. So everything that is in the compiler right now that could be a function ends up being a function.

There are a few advantages to that:

  • it keeps the compiler minimal
  • all optimisations or mutations that can be done on the alpaca ast also a apply to those kernel functions
  • it's a nice bit of dogfooding
  • more of the code will be typed out of the box

And some disadvantages:

  • testing the compiler w/o the kernel gets more complicated.

I've not read every line of the compiler but most notabley are the mathematical operators. Instead of a special compiler case for them they'd turn into something like:

let (+) left right =
  match (left, right) with
   (l, r), is_integer i, is_integer r -> beam :erlang :+ [left, right]
@Licenser
Copy link
Contributor Author

Oh I forgot the most important part, kernel.alp would be loaded into the global namespace like the + function in erlang is.

@lpil
Copy link
Contributor

lpil commented Jan 2, 2018

Would any overhead would be introduced by wrapping functions like that?

@j14159
Copy link
Collaborator

j14159 commented Jan 2, 2018

I think the only overhead would be the guard functions, not sure what the impact is there though tbh. We could do this all with type specs now although I'm not sure that would set the best example :)

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

3 participants