The code you show does not and cannot implement multiple servers with different names, since the server name is defined as the same as the module name. So if you try with this code to get multiple servers implemented in one module your attempts will fail. The reason for introducing separate SERVER macro with the same value as MODULE is to make things more explicit. In start_link call the two macros may have the same value, but they serve different purposes, so it is clearer to use two instead of one.
1条答案
按热度按时间vsikbqxv1#
The code you show does not and cannot implement multiple servers with different names, since the server name is defined as the same as the module name. So if you try with this code to get multiple servers implemented in one module your attempts will fail.
The reason for introducing separate SERVER macro with the same value as MODULE is to make things more explicit. In start_link call the two macros may have the same value, but they serve different purposes, so it is clearer to use two instead of one.