Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

behaviour won't work on a module transformed by pmod_pt #2

Open
tatsuya6502 opened this issue Mar 11, 2013 · 3 comments
Open

behaviour won't work on a module transformed by pmod_pt #2

tatsuya6502 opened this issue Mar 11, 2013 · 3 comments

Comments

@tatsuya6502
Copy link

Related to: rabbitmq/erlando#12 (comment)

It seems a module can't have both -behaviour(..) and -compile({parse_transform, pmod_pt}) at the same time. I think the reason is behaviour tries to validate callback functions after pmot_pt is applied(?)

state_t.erl

-module(state_t, [InnerMonad]).
-compile({parse_transform, do}).
-compile({parse_transform, pmod_pt}).

-behaviour(monad).
-export(['>>='/2, return/1, fail/1]).
...

monad.erl

behaviour_info(callbacks) ->
    [{'>>=',  2},
     {return, 1},
     {fail,   1}];

state_t module doesn't compile:

src/state_t.erl:21: undefined callback function '>>='/2 (behaviour 'monad')
src/state_t.erl:21: undefined callback function fail/1 (behaviour 'monad')
src/state_t.erl:21: undefined callback function return/1 (behaviour 'monad')

If I remove -behaviour(monad), it compiles. Note that each function has an extra parameter (e.g. '>>='/3, not '>>='/2)

Erlang R16B (erts-5.10.1) [source] [64-bit] [smp:4:4] [async-threads:10] [hipe] [kernel-poll:false]

Eshell V5.10.1  (abort with ^G)
...
3> state_t:module_info().
[{exports,[{'>>=',3},
           {return,2},
           {fail,2},
           {get,1},
           {put,2},
           {eval,3},
           {exec,3},
           {run,3},
           {modify,2},
           {modify_and_return,2},
           {lift,2},
           {new,1},
           {instance,1},
           {module_info,0},
           {module_info,1}]},
@carlosmarin
Copy link

Noticed the same issue.

@richcarl
Copy link

The problem is not with the parse transform itself, but that the behaviour callback check in the compiler doesn't understand the parameterized module, whose actual functions have an additional parameter. And since the support for parameterized modules has been dropped from the compiler, there is no way this can be added now. In short, you can't combine behaviour declarations and parameterized modules.

@carlosmarin
Copy link

Understood, thanks for clarifying.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants