[erlang-questions] compile options+documentation consistency

Danil Zagoskin z@REDACTED
Wed Jun 6 13:00:03 CEST 2018

One thing more (to not create extra thread)

In the documentations there are notes describing some options behaviour,
> The options {nowarn_unused_function, FAs}, {nowarn_bif_clash, FAs}, and
{nowarn_deprecated_function, MFAs}
> are only recognized when given in files. They are not affected by options
> warn_unused_function, warn_bif_clash, or warn_deprecated_function.

It's hard to notice them if you read about affected options — this note is
almost 2 screens below
the nowarn_deprecated_function description.

Maybe it would be easier to read the note if affected options had a link to
it, e.g.

> {nowarn_deprecated_function, MFAs}
> (This option works only when given in a file and has a precedence over
warn_deprecated_function option. See Note [4] for details)
> Turns off warnings for calls to deprecated functions
> does, but only for the mentioned functions. MFAs is a tuple
{Module,Name,Arity} or a list of such tuples.

On Wed, Jun 6, 2018 at 1:16 PM, Danil Zagoskin <z@REDACTED> wrote:

> Hi!
> 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
> contains AST.
> Passing both 'to_pp' and 'binary' works as I wanted — AST in returned
> tuple, no files written.
> My suggestions:
> * 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 AST)
> * 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

Danil Zagoskin | z@REDACTED
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20180606/84dd3786/attachment.htm>

More information about the erlang-questions mailing list