Search code examples
opa

What exactly is meant with 'top-level' in an Opa program?


I was browsing the source of the OpaDo program and noticed that in the module Todo a function called mypage got called. This function is declared in the file 'ui', but nowhere in the file todo.opa does the ui.opa file get imported.

Is this what is meant with 'top-level'? Are all functions declared outside of modules freely accessible? How about types or records?

Does the compiler recognise this dependency and will it compile ui.opa automatically when asked to compile todo.opa?


Solution

  • By default, all opa source files belong to the same default package.

    So that's why when you compile todo.opa and ui.opa, all functions, types and records are available for the other files in the same package.

    "top-level" means a declaration at first level of the source file, not inside a function.

    The compiler should compile just the necessary files when you use multiple packages.