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

Allow for arbitrary module attributes #21

Open
leostera opened this issue Oct 21, 2020 · 0 comments
Open

Allow for arbitrary module attributes #21

leostera opened this issue Oct 21, 2020 · 0 comments
Labels
compiler Related to the OCaml to Erlang compiler enhancement New feature or request

Comments

@leostera
Copy link
Owner

leostera commented Oct 21, 2020

While working on #19, the error traces pointed out that the Process.spawn function was shadowing Erlang's spawn. This can be overcomed with a compiler directive, which we can't write at the moment, such as -compile({no_auto_import, [spawn/1]})..

Allowing these compiler directives is useful for:

  • redefining functions with standard names
  • allowing NIF on_load functions to be defined
  • adding more module-level attributes such as author or vsn

One way to fix this is to just use the compiler annotations where we can embed a string of raw Erlang, parse it, and merge it with the translated AST.

[@caramel.raw {|
-compile({no_auto_import, [spawn/1]}).
|}]

Definitely not pretty, but should be enough to unblock this while we figure out what the proper syntax for this is. Another alternative would be:

Caramel.ModAttributes.[
  compile (no_auto_import [ funref `spawn 1 ]); 
] [@caramel.module_attributes]

but building a DSL for this feels like a lot more work right now.

@leostera leostera added enhancement New feature or request compiler Related to the OCaml to Erlang compiler labels Oct 21, 2020
@leostera leostera added this to the v0.2 milestone Oct 21, 2020
@leostera leostera removed this from the Typechecking Erlang as OCaml milestone Oct 30, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compiler Related to the OCaml to Erlang compiler enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant