Allowing of "leaking" internals #24822
Unanswered
j-mie6
asked this question in
Metaprogramming
Replies: 1 comment 3 replies
-
|
Are you aware of the |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Often, I'd like it so that my macros can make use of "internal" library functionality not available to the user (which I denote via
private [library]qualifiers on classes/methods). I don't want the users to see these things, as it introduces noise into the documentation for stuff that might have invariants or other things that mean I don't think they should be playing around with them (if they really want to, they can make something inpackage library).However, with the way that inlining works, if you use a
private [library]thing in a macro, the underlying implementation will (necessarily) leak into the user package. That could be considered a feature, or it could be considered a bug. As long as the macro is defined withinpackage library, I see no reason to stop me from allowing access toprivate [library]members within the macro -- I am in charge of whether or not these things should escape, and from a bytecode perspective, they are technically bytecode public anyway, so no issues there.An argument could be made that this could circumvent the binary compatibility checks if used improperly: if I expose a
foowith the private qualifier, then MiMA would skip over it for checks, but that means a modification could silently pass through for a library that had compiled against mine and used the macro in the process -- not ideal.It might be nice if there was a middle-ground. I can declare something as
private [library], but denote somehow that I allow (and intend) for macros to "expose" it to the user in a controlled way, and that we should be careful to ensure it's binary API remains consistent (i.e. treat it as public). Thoughts?Beta Was this translation helpful? Give feedback.
All reactions