Skip to content
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

Split augmentations into improved part files and augmentation declara… #3800

Merged
merged 6 commits into from
Jun 28, 2024

Conversation

lrhn
Copy link
Member

@lrhn lrhn commented May 14, 2024

…tions.

Unifies "augmentation libraries" and part files.
Part files can have imports, exports and further part files. Part files can use configurable URIs.
A part of directive can no longer use a library name. Part files inherit the imports of their parent file, and can extend or shadow those with their own imports.

Augmentation declarations can occur in any part or library file. An augmentation must occur "below" the declaration it augments: Either later in the same file ("below" when viewing code), or in the file-tree of a part file of the same file ("below" in the part-file tree of the library).

This ensures that the original declaration occurs above all augmentations of it, and that all augmentations of the same original declaration occur on a single path down the part-file tree of the library. What again ensures that reordering part directives does not change the order of augmentations.

Changed the lexical scope of augmenting class-like declarations (declarations with a member scope) to only contain the members declared inside the same class-like declaration, not the collection of all members declared by all declarations with the same name.

Rewrote the part about applying augmentations. This is more speculative since it doesn't provide a complete definition, but more of a pattern for extending semantics that assume a name refers to a single declaration, into one where a name denotes a set (stack depending on augmentation application order), of individual syntactic declarations.
The existing semi-syntactic "merging" may not be a viable specification approach, since it requires merging code from different scopes into a single scope. That's not impossible, we also move code around for mixin applications, but it's also easy to get wrong.

@davidmorgan
Copy link
Contributor

Whoops, I thought this was an issue; it's a PR. Opened #3848 so we have an issue for this.

working/augmentation-libraries/feature-specification.md Outdated Show resolved Hide resolved
working/augmentation-libraries/parts_with_imports.md Outdated Show resolved Hide resolved
working/augmentation-libraries/parts_with_imports.md Outdated Show resolved Hide resolved
working/augmentation-libraries/parts_with_imports.md Outdated Show resolved Hide resolved
working/augmentation-libraries/feature-specification.md Outdated Show resolved Hide resolved
working/augmentation-libraries/feature-specification.md Outdated Show resolved Hide resolved
working/augmentation-libraries/feature-specification.md Outdated Show resolved Hide resolved
working/augmentation-libraries/feature-specification.md Outdated Show resolved Hide resolved
Copy link
Member Author

@lrhn lrhn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed. Will land now and use this as base for any further changes.

working/augmentation-libraries/parts_with_imports.md Outdated Show resolved Hide resolved
working/augmentation-libraries/parts_with_imports.md Outdated Show resolved Hide resolved
working/augmentation-libraries/feature-specification.md Outdated Show resolved Hide resolved
lrhn added 5 commits June 28, 2024 15:23
…tions.

Unifies "augmentation libraries" and part files.
Part files can have imports, exports and further part files.
Part files can use configurable URIs.
A `part of` directive can no longer use a library name.
Part files inherit the imports of their parent file, and can
extend or shadow those with their own imports.

Augmentation declarations can occur in any part or library file.
An augmentation must occur "below" the declaration it augments:
Either later in the same file ("below" when viewing code),
or in the file-tree of a part file of the same file ("below" in
the part-file tree of the library).

This ensures that the original declaration occurs above all
augmentations of it, and that all augmentations of the same
original declaration occur on a single path down the part-file tree
of the library. What again ensures that reordering `part` directives
does not change the order of augmentations.

Changed the lexical scope of augmenting class-like declarations
(declarations with a member scope) to only contain the members
declared inside the same class-like declaration, not the collection
of all members declared by all declarations with the same name.

Rewrote the part about applying augmentations. This is more
speculative since it doesn't provide a complete definition,
but more of a pattern for extending semantics that assume a
name refers to a single declaration, into one where a name
denotes a set (stack depending on augmentation application order),
of individual syntactic declarations.
The existing semi-syntactic "merging" may not be a viable
specification approach, since it requires merging code
from different scopes into a single scope. That's not impossible,
we also move code around for mixin applications, but it's also
easy to get wrong.
@lrhn lrhn force-pushed the augment-spec-update branch from 9ed33c1 to bf5fc86 Compare June 28, 2024 13:24
@lrhn lrhn merged commit 70e5694 into main Jun 28, 2024
3 checks passed
@lrhn lrhn deleted the augment-spec-update branch June 28, 2024 13:32
chooses the URI that the `part` directive refers to, and after that the
included file works just as any other part file.

It’s a **compile-time error** if a Dart (parent) file with URI *P* has a `part`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When I read this paragraph, it seems that there are a few typos.

"does not parse as a <partDirective>" - maybe < partDeclaration >?

"does not denote the library of P" - we can have partDirectives not only in libraries, so maybe "the file with URI P"?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK, <partDeclaration> for the entire part file, <partDirective> for the part "..."; directive.
And yes, "the file P" is correct. (Damn! I hoped I had found all of the places that assumed a parent file was a library.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants