-
Notifications
You must be signed in to change notification settings - Fork 205
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
Fragmented declarations #4203
Comments
I admit I don't have a mental model of how this all works, and maybe I shouldn't comment, but if the following is silly, I am ready to delete this comment. |
The entire point is to allow you to modularize a single library in a type safe way. With no other features, you don't really need the signature declarations, it's just a way to spread a class over multiple files. If we include conditional part directives, it's a way to specify a signature, and have a platform dependent implementation which is guaranteed to have that signature. With code generation, macros or plain, it allows generated code to supply the implementation of an already specified signature, but not the more complicated feature of changing or wrapping existing implementation, which is one of the biggest sources of complexity in the augmentations feature. |
I see. It's for a single library, where each part is aware of what other parts are doing. 👍 |
Would it work the same as the |
@lrhn: |
The You can locally see the gaps in the implementation, but from the outside you can only see the single unified facade. |
It's within a library, in a sense that after all macro annotations are applied, the |
The enhanced parts and augmentations features makes it easier to contain the implementation details of a class in one file, while defining the signatures in another. Possibly even an implementation guarded by a conditional part directive.
Maybe this can also be achieved by a less complicated feature than the currently proposed augmentations:
"Fragment declarations" are like augmenting declarations in that more than one declaration can exist with the same name in the same library or scope, and they are combined into the actual API and implementation.
Unlike augmenting declarations at most one of the declarations for a function/member can be concrete. All other declarations must be signature declarations which only specify the API (kind, types, capabilities), but no implementation details (body, initializer lists, default values).
That means that there is no need for an
augmented
feature, since there is no augmented implementation to access.There is also no way to change an existing implementation, so this is entirely a code management feature, and possibly (using conditional parts) a patch-like feature.
It may not be enough for macros, if they need to augment existing implementation, but it can be enough for manually written modular code, maybe even for some code generation.
(No extra keywords needed, just allowing multiple declarations of the same kind in the same namespace, as long as there is never two concrete declarations for the same thing, and at least one for declarations that cannot be abstract. Can allow, fx,
part class Foo
on declarations off classes, or similar, which so not declare a superclass. May need new syntax for declaring signatures for static members and constructors, which cannot be abstract today.)And there is no ordering dependency, not unless two class declarations are both allowed to add mixins.
The text was updated successfully, but these errors were encountered: