ta0kira / zeolite

Zeolite is a statically-typed, general-purpose programming language.
Apache License 2.0
18 stars 0 forks source link

Allow modules to have private public categories. #41

Closed ta0kira closed 4 years ago

ta0kira commented 4 years ago

All categories in .0rp source files are visible outside of the module. There should be a way to mark certain categories as private to the module, probably in .zeolite-module.

ta0kira commented 4 years ago

Three options:

  1. Do this on a per-.0rp basis in .zeolite-module. This should be straightforward.

  2. Do this on a per-category basis. This would require somehow marking a category is private in the type map so that lookup fails. This would likely need to be done with a comparison between the public namespace of the module being compiled vs. that of the module owning the category.

    • Marking categories as private in the source files would require a change in the language.
    • Marking categories as private in the .zeolite-module adds hidden behavior that would still require a comment next to the category in the .0rp.
  3. Just require that anything private live in a subdirectory that's listed as a private dep. The only real drawback here is that it would be difficult to make a private+public pair of categories depend on each other internally.

Overall, I like the 3rd option because it's no work for me, and it's also more clear to the user because the private files are in a different directory.

ta0kira commented 4 years ago

Actually, I think option 1 is better, so that breaking up monolithic .0rx sources doesn't require creating a subdirectory.

Rather than putting this in .zeolite-module, it could just be some sort of pragma. This obviously requires coming up with reasonable syntax and semantics for pragmas in general, as well as error/warning behavior.