[erlang-patches] Put compile options from code into parse_transform/2 options variable

Enrique Fernández Casado efcasado@REDACTED
Thu May 1 19:47:54 CEST 2014


AFAIK, there is no way to specify per-transform options. So
all four compile options will end up in the "options" variable
of the two specified parse transforms. Exactly as if you had
compiled "dummy_module" as:

erlc "+{parse_transform, dummy_transform1}" "+{parse_transform,
dummy_transform2}" \
+dummy_transform_option +other_dummy_transform_option dummy_module.erl

If someone were to implement support for per-transform options,
it may be worth considering to add an (optional) third element to
the "parse_transform" compile option (i.e. {parse_transform, Module, Opts}).

Regards,
Enrique


2014-05-01 14:51 GMT+02:00 Fred Hebert <mononcqc@REDACTED>:

> What happens if I have a module defined as:
>
>     -module(dummy_module).
>
>     -compile({parse_transform, dummy_transform1}).
>     -compile({parse_transform, dummy_transform2}).
>     -compile(dummy_transform_option).
>     -compile(other_dummy_transform_option).
>
> How does that end up working?
>
> Regards,
> Fred.
>
> On 05/01, Enrique Fernández Casado wrote:
> > Put compile options from code (i.e. -compile(myoption1)) into the options
> > variable used as second argument in parse_transform/2. This makes it
> > possible to access all compile options (i.e. the ones specified in the
> > command-line and the ones specified in code) in a consistent way.
> >
> > Here is a simple example:
> >
> > (dummy_module.erl)
> >
> > -module(dummy_module).
> >
> > -compile({parse_transform, dummy_transform}).
> > -compile(dummy_transform_option1).
> >
> >
> >
> > (dummy_transform.erl)
> >
> > -module(dummy_transform).
> >
> > -export([parse_transform/2]).
> >
> > parse_transform(Forms, Opts) ->
> >     true = lists:member(dummy_transform_option1, Opts),
> >     Forms.
> >
> >
> > Links:
> >
> > git fetch git://github.com/efcasado/otp.git compile-options
> >
> > https://github.com/efcasado/otp/compare/erlang:maint...compile-options
> >
> https://github.com/efcasado/otp/compare/erlang:maint...compile-options.patch
> >
> > https://github.com/erlang/otp/pull/350
>
> > _______________________________________________
> > erlang-patches mailing list
> > erlang-patches@REDACTED
> > http://erlang.org/mailman/listinfo/erlang-patches
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-patches/attachments/20140501/4cdede11/attachment.htm>


More information about the erlang-patches mailing list