- What’s the name of the object?
We could name it the name of the file (what Ammonite does) or possibly with a mangling/suffix/prefix to avoid naming conflicts with normally-defined classes. We could do either, since there’s no backwards compatibility concern since
*.sc entrypoint files do not currently exist.
- What about hiding implementation details of the main program block from the rest of the package?
I think we should just ban usage of things in the
*.sc entrypoint files from
*.scala library files. That would more or less already match the best practices in most scripting languages, and wouldn’t hinder any of the benefits described in either of these threads (getting started with single file, growing to a multi-file project, similarity with other languages, …)
- What about the static initialization lock?
If we’re going to limit usage of
*.sc files in
*.scala files as described above, we could wrap the
*.sc body in the main method. No more object initialization problems, and the contents of
*.sc would be invisible and un-importable from other files as we would want.