-
Notifications
You must be signed in to change notification settings - Fork 410
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Private modules and scope #1478
Comments
Private modules were intended to be accessible only from a single library. In the context of a scope, private and public refer to libraries so there's no contradiction. I recall two ideas being thrown around for sharing code that is visible only inside a scope:
IIRC @nojb had some ideas regarding this as well in case I'm missing something. |
I think I don't get clearly what "determine" in But I was clearly not clear in my first message, I edited it. Indeed |
Or at most 3 fields of the four |
I'd prefer that modules were private by default (except for the lib interface module). Protected is not a very good default because most users do not have a good intuition for what a scope is, and the use case for protected modules is narrow enough that we're not yet convinced if the feature should be added at all. |
FWIW the current design for the migration of Frama-C needs it:
I agree it is not simple and scopes are not the good level for protected modules because the packages of the same scope can be installed at different time. So I though that protected would allow visibility only to the library of the same package.
What do you prefer if there is no lib interface module? The default module alias defines nothing if the other modules are private. EDIT: remove |
If I understand it correctly, you would like to define protected modules in the Otherwise, you would indeed something like protected modules
Your suggestion of doing Another idea to consider would be to make the
In this scheme, we could provide some default scopes such as
Isn't this what we want? The modules should default to private rather than public. Those who don't like this default can always invert it with |
It is possible but not just by moving modules, because some shared private module could depend on public module. So some re-export would be needed. However I think #1017 is a good thing to have (except for the third restriction).
We have the question of the
That would mean that if one define a library stanza with minimal fields, they can't use it. I prefer the default of an |
To expand on the potential use cases of For example, consider a library:
At the moment, I don't think it's possible to make I'd like a way to either force linking |
@emillon I think I just confused the package private and the protected modifiers in java. In which case I agree that
Don't you mean compile? Linking against the private modules is always possible as the archives will stay there. It's the cmi's that are hidden.
So this is a 3rd access scope. We now want modules that are visible to tests, but are still going to be invisible to other libraries in the package. I guess this is why I'm inclined to make something more flexible right off the bat. |
Yes, I was thinking more generally that it's impossible to create an executable referring to these modules.
I haven't thought of that, but yes this seems to be something separate. Though the most important part of private modules is that they're not visible to the exterior. I think it could be acceptable if they were visible inside the project, but if we can find a flexible solution this is even better. |
In @Emilion case we just want them to not be visible from the exterior, they could be visible inside the package. So since |
You don't think it's useful to have levels of visibilities within a package? I don't follow that a module that is visible to the tests should be visible to all libraries within the same package as well. But it's not such a bad approximation either. |
If this was the only visibility knob we had, I think that it would be manageable. The number one thing I'd like to avoid as a package maintainer is other packages depending on non-public API. Having properly isolated opam packages within a module is a nice property, but it's easier to check "by hand" since all the source code is in the same repository. That could be a lint rule for example. That being said, I'm fine if there's finer control, but I'm worried it will make the semantics and configuration more complicated later on. |
So after discussion we agreed on, for a library
|
Closing this as there doesn't appear to be anything actionable. |
In the documentation for private modules it is written:
In the documentation for scope it is written:
Is a library
foo.b
able to access the private libraries offoo.a
(given thatfoo.opam
exists)? The too quotes seems to imply different answers.Currently it seems
foo.b
can't access them. In #106 the contrary was tried and refined multiple times.EDIT: I mean't
private modules of `foo.a`
when I wroteprivate libraries of `foo.a`
The text was updated successfully, but these errors were encountered: