functionerlangenvironmentpidinfo

erlang change a fun environment


Would it be possible to change the environment variables of an erlang fun without interfering with the code concerning the function definition and the lambda lifting?

Specifically I would like to explicitly change the pid(<12036.69.0>) on the env of a fun that has this info:

[{pid,<12036.68.0>},
 {module,expl},
 {new_index,7},
 {new_uniq,<<197,235,209,205,33,163,202,255,8,58,234,128,135,166,147,185>>},
 {index,7},
 {uniq,103767694},
 {name,'-test_no_pid/0-fun-1-'},
 {arity,0},
 {env,[<12036.69.0>]},
 {type,local}]

It does not matter what the fun does since I want this solution to be a general one that just changes all the pids on the env of the fun.


Solution

  • No, that would break the referential transparency property of the fun as a constant value. It's no different from updating a field of a tuple, and such a destructive change could even make the garbage collector crash because it violates the internal assumptions about directions of pointers.