[erlang-questions] Process scope variable

zxq9 <>
Tue Feb 17 16:51:11 CET 2015


On 2015年2月17日 火曜日 15:18:27 Imants Cekusins wrote:
> > Why not a() -> 10.
> > b() -> a() + 1.
> 
> Let's say, there is a long chain of function calls. Some of them need
> A, some of them don't.
> 
> Let A be clearly static, defined early in the process.
> 
> Using process dict, I will pass only relevant vars from fun to fun,
> not messages to some other funs down the line.

I think part of the conceptual problem is that you're missing the distinction 
between messages and arguments -- they are not the same thing.

In any case, someone has already mentioned the process dictionary, and given a 
tongue-in-cheek warning about its use. The former provides an exact 
implementation of the functionality you seem to desire, the latter was a 
rather understated and brief version of the obligatory warning against 
abandoning one of Erlang's greatest benefits.

-Craig


More information about the erlang-questions mailing list