开发者

Can can I call a function in the same Erlang Parameterised module?

开发者 https://www.devze.com 2023-01-03 08:04 出处:网络
I have a paramterised module in Erlang in which I wish t开发者_StackOverflowo call a function A from within function B of the same parameterised module. How can I do this?From this paper:

I have a paramterised module in Erlang in which I wish t开发者_StackOverflowo call a function A from within function B of the same parameterised module. How can I do this?


From this paper:

in every function of an abstract module, the variable THIS is always implicitly bound to the current module instance

So you can simply write inside a function B:

THIS:A().


Just to recapitulate in an answer. You don't have to do anything special to call functions within a parametrised module, just write the code as you normally would. It is only when want to make an "remote" call to an exported function from within the module you need THIS:a(). Externally you need the parametrised module reference.

Though I agree with @Christian, stay away from them, you don't really need them.

0

精彩评论

暂无评论...
验证码 换一张
取 消