[erlang-questions] compile options+documentation consistency
Wed Jun 6 12:16:53 CEST 2018
I had a simple task: get an AST of a module (.erl) after preprocessing it
(includes + parse_transforms).
I read the docs: http://erlang.org/doc/man/compile.html
This is how I first understood some options:
* 'P' — get a transformed code instead of a compiled module
* 'binary' — get a result in return value instead of a file
So, I run compile:file("example.erl", ['P', binary]) and indeed get an AST
in third position of returned tuple.
Surprise: example.P file is still written on disk, and it contains Erlang
code, not the returned AST.
Reading the compile.erl I found an undocumented 'to_pp' option.
Passing 'to_pp' alone also generates example.P file, but this time it
Passing both 'to_pp' and 'binary' works as I wanted — AST in returned
tuple, no files written.
* make 'binary' (well, naming legacy) always switch from only writing to
file to only returning result.
* associate every content with its own file extension (e.g. example.ast for
* document 'to_pp' and other options
This would make using compiler in non-trivial way easier:
* choose at which pass should compiler stop
* choose where the result goes
Any thoughts on this?
Danil Zagoskin | z@REDACTED
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the erlang-questions