Passing functions between processes

Sending a function from one node to another is very sensitive and needs to be done very carefully. So doing a Node.spawn/2 with a fn or sending a fn requires that the module in which the fn is defined is already loaded on the other node. It also demands that it is exactly the same version of the module without any changes and preferably the same compiled code.

The reason for this is that when a module is compiled an md5 checksum of the code is included in the module definition. Internally a function includes the name of the module in which it is defined and that modules checksum. When it is called the module name is used to find the function code and the checksums are compared, and they have to be the same.

8 Likes