caramel
caramel copied to clipboard
Allow for arbitrary module attributes
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_loadfunctions to be defined - adding more module-level attributes such as
authororvsn
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.