2

For example, if I create file jopa.erl with this code inside ...

-module(jopa).

...everything compiles without errors

However, if I put this code inside jopa.erl ...

-module(lol).

and try to compile...

2> c(jopa).
./jopa.beam: Module name 'lol' does not match file name 'jopa'
error

... I see an error

So, what's the point to specify module name if script even doesn't compile with another filename?

2
  • A file name can be changed easily by external programs, so depending on it would be fragile. Commented Aug 21 at 19:01
  • @choroba but how it solves the issue if the file won't compile with another filename (sorry for probably stupid question, i am new to Erlang) Commented Aug 21 at 19:25

1 Answer 1

0

As explained in the Erlang module documentation, code loading doesn't work as intended if the module and file names don't match. For example, in interactive mode, modules are found by their filenames via the code path, which is a list of directories to search for compiled modules.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.