Patch to allow parameterized modules in parse transforms

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Patch to allow parameterized modules in parse transforms

Matthew Dempsky-3
The Erlang compiler does not currently allow parameterized modules to
be used for parse transforms, but only because of a bad atom_to_list
call.  I replaced this with io_lib:format and it seems to work.

--- compile.erl~ 2007-10-31 07:05:39.000000000 -0700
+++ compile.erl 2007-11-19 14:12:43.000000000 -0800
@@ -765,7 +765,7 @@
     end.

 foldl_transform(St, [T|Ts]) ->
-    Name = "transform " ++ atom_to_list(T),
+    Name = lists:flatten(io_lib:format("transform ~p", [T])),
     Fun = fun(S) -> T:parse_transform(S#compile.code, S#compile.options) end,
     Run = case member(time, St#compile.options) of
       true  -> fun run_tc/2;


Reply | Threaded
Open this post in threaded view
|

Patch to allow parameterized modules in parse transforms

Björn Gustavsson-3
"Matthew Dempsky" <matthew> writes:

> The Erlang compiler does not currently allow parameterized modules to
> be used for parse transforms, but only because of a bad atom_to_list
> call.  I replaced this with io_lib:format and it seems to work.

I don't want to include this patch as there is no portable way
to use a parameterized module in a compile directive embedded in
a source file.

We might implement another solution for using parameterized modules
as parse transforms later, when/if parameterized modules have become
a support part of the language.

/Bjorn

> --- compile.erl~ 2007-10-31 07:05:39.000000000 -0700
> +++ compile.erl 2007-11-19 14:12:43.000000000 -0800
> @@ -765,7 +765,7 @@
>      end.
>
>  foldl_transform(St, [T|Ts]) ->
> -    Name = "transform " ++ atom_to_list(T),
> +    Name = lists:flatten(io_lib:format("transform ~p", [T])),
>      Fun = fun(S) -> T:parse_transform(S#compile.code, S#compile.options) end,
>      Run = case member(time, St#compile.options) of
>        true  -> fun run_tc/2;
> _______________________________________________
> erlang-patches mailing list
> erlang-patches
> http://www.erlang.org/mailman/listinfo/erlang-patches
>

--
Bj?rn Gustavsson, Erlang/OTP, Ericsson AB