Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I have a "private" Erlang module?

Tags:

module

erlang

I prefer working with files that are less than 1000 lines long, so am thinking of breaking up some Erlang modules into more bite-sized pieces.

Is there a way of doing this without expanding the public API of my library?

What I mean is, any time there is a module, any user can do module:func_exported_from_the_module. The only way to really have something be private that I know of is to not export it from any module (and even then holes can be poked).

So if there is technically no way to accomplish what I'm looking for, is there a convention? For example, there are no private methods in Python classes, but the convention is to use a leading _ in _my_private_method to mark it as private.

I accept that the answer may be, "no, you must have 4K LOC files."

like image 464
Max Heiber Avatar asked Mar 03 '23 01:03

Max Heiber


1 Answers

The closest thing to a convention is to use edoc tags, like @private and @hidden.

From the docs:

@hidden

Marks the function so that it will not appear in the documentation (even if "private" documentation is generated). Useful for debug/test functions, etc. The content can be used as a comment; it is ignored by EDoc.

@private

Marks the function as private (i.e., not part of the public interface), so that it will not appear in the normal documentation. (If "private" documentation is generated, the function will be included.) Only useful for exported functions, e.g. entry points for spawn. (Non-exported functions are always "private".) The content can be used as a comment; it is ignored by EDoc.

like image 109
Brujo Benavides Avatar answered Mar 05 '23 16:03

Brujo Benavides