Can all functions from a module be imported into Erlang?

I cannot figure out how to import all the functions of a module without specifying individual functions.

+6
erlang
source share
3 answers

As the Christian says, "it is impossible to import all functions from a module." The compiler does not have an import_all directive, and I think that this is done intentionally to prevent excessive import of functions.

Importing functions instead of their full qualifications M:F(...) usually bad. There is a semantic difference between calling a module-local function and a function in another module (code loading rules), so I think it's best to make other people's calls explicit. It would be possible to make exceptions for importing the functions of the dict / lists / sets module, since they are usually understood and are unlikely to change during the code update.

+9
source share

Unable to import all functions from the module.

+7
source share

Reading from Erlang Programming Rules :

Do not use -import, using it, the code is more difficult to read, since you cannot directly see in which module the function is defined. Use exref (Cross Reference Tool) to find module dependencies.

+6
source share

All Articles