-
Notifications
You must be signed in to change notification settings - Fork 2
RFC: Forced zones #4
Comments
I think all code should be global and can be globally referenced by default, however. I think you should be able to define local zones (e.g, only files in the same zone can reference, access, modify). |
What about namespacing? Do you mean all zones are inherently global? I worry about global namespace pollution and conflicts. |
Ah this is true. |
I think that's essentially what was planned. However, forcing a particular filesystem seems too controlling to me. Java requires package source files to be laid out in a directory hierarchy. Further, it forces a one-class-per-file style, which in my opinion makes too many decisions on a project's structure and encourages the (mis)use of inner classes and whatnot. However, on the flip side, if we allow zones but don't enforce a hierarchy on the filesystem, we achieve flexibility in the way projects are designed (e.g. you could use a hierarchy similar to java, or you could simply do a flat project system like C's). In essence, I foresee the semantics looking something like:
However that adds an indentation level that would otherwise be pointless, especially if your files only contained one zone. On the topic of forced zones (where all of your code must be in a zone), that brings up the question of entry points. I really like that feature of Java, but that does introduce some extra configuration - either during the build, or upon execution. Neither of those avenues seem convenient. I think the topic needs to be taken back a step and really ask what should namespaces solve? There is the obvious answer - it prevents pollution and conflicts. However, when it comes to depending on other namespaces/their contents, I think there is something to be desired by some of the ways they're implemented in languages. |
I think in the end result... A language that doesn't enforce hierarchy will be the one that wins. Because now it's not placing any sort of file/module layout constraints on the programmer. |
If anything it'll make dependencies more ambiguous. Having a strict hierarchy makes things very clear as to which things should be referenced from where. Not having a hierarchy can cause ambiguity. As far as semantics go, I don't see how either of them would cause the compiler any trouble. Humans, on the other hand, are a consideration here as well. |
True, either way is good (won't matter to the compiler). |
After working with Python a lot more I think Python's module model works very well for native code.
mymodule/mymain.ar
mymodule_tests/test.ar
|
Should all code be forced into a zone (namespace)? The dependency system already uses a folder structure to segregate into zones, similar to Java. However, Java allows the use of a default package, which doesn't allow any other code to reference members in the default package.
The text was updated successfully, but these errors were encountered: