How to share an entry between multiple erl in Erlang?

I would like to use -record in every erl file that I have. I know that I can repeat the recording separately in each file, but it is really ugly.

Any suggestion?

PS: Be gentle ;-) I am new to Erlang.

+4
source share
1 answer

Put your record definition in the header file (.hrl). For example, animal.hrl might look like this:

 -record(animal, {name, legs=4, eyes=2}). 

Then you can include the .hrl file in your .erl files as follows:

 -include_lib("animal.hrl"). 
  • I would recommend reading this one .
  • Please note that the .hrl file should probably be placed in your src directory if it is not needed outside your application - in this case you should place it in a directory called include .
+9
source

Source: https://habr.com/ru/post/1397792/


All Articles