-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Code and name organization #107
Code and name organization #107
Conversation
Move firebase support into a src directory. (#15)
Update fork
- We should make it easy to refactor code, including moving code between | ||
files. This includes refactoring both by humans and by developer | ||
tooling. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The goals/philosophy should include something that might be called "the library user's bill of rights".
Some of the following is perhaps stated elsewhere, but here is a great place for it, and furthermore, there
is a long and rich history of programming language designs getting this wrong! (e.g. C++ and Haskell.)
The person importing a library should have complete control over which names come into scope
and the ability to rename the imported entities. The crucial scenario to think about is that the
person is importing from two libraries and those two libraries were developed by people that don't know or care about each other, or perhaps even dislike each other! So the two libraries may have lots of name conflicts. But nevertheless, it should be possible for someone to import both libraries and apply the appropriate renamings to resolve the conflicts they care about.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Name conflicts are noted in the actual proposal file (p0107.md) as out of scope for this proposal; either the aliasing or name lookup proposal should address it more directly. While it's an important issue, they are nuanced discussions that require a more complex discussion, this proposal is already quite large, and there's dissent around whether renaming imports would be necessary. I want to keep the proposal's scope at a level where it's straightforward to review, and so it is not a goal addressed by this feature design, at least at present.
I'm wary too of the meaning of "complete control". I think this overlaps with the idea of renaming, as responded to above.
Note, I think the goal on line 96 captures what you're trying to address, as far as it affects this design:
- We should support libraries adding new structs, functions or other
identifiers without those new identifiers being able to shadow or break
existing users that already have identifiers with conflicting names.
Please make suggestions on phrasing if this isn't direct enough for you, although I'm trying to keep possible implementations of this goal to the rest of the design.
Please also note the "Broader imports, either all names or arbitrary code" alternative, which dives into the related tradeoffs a little more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If there's a better place to address this concern, that's fine.
Regarding the goal on line 96, that doesn't quite cover this concern
because it only talks about the consequences to existing users of adding new identifiers.
But this concern also applies to new users.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Responding to comments
- We should make it easy to refactor code, including moving code between | ||
files. This includes refactoring both by humans and by developer | ||
tooling. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Name conflicts are noted in the actual proposal file (p0107.md) as out of scope for this proposal; either the aliasing or name lookup proposal should address it more directly. While it's an important issue, they are nuanced discussions that require a more complex discussion, this proposal is already quite large, and there's dissent around whether renaming imports would be necessary. I want to keep the proposal's scope at a level where it's straightforward to review, and so it is not a goal addressed by this feature design, at least at present.
I'm wary too of the meaning of "complete control". I think this overlaps with the idea of renaming, as responded to above.
Note, I think the goal on line 96 captures what you're trying to address, as far as it affects this design:
- We should support libraries adding new structs, functions or other
identifiers without those new identifiers being able to shadow or break
existing users that already have identifiers with conflicting names.
Please make suggestions on phrasing if this isn't direct enough for you, although I'm trying to keep possible implementations of this goal to the rest of the design.
Please also note the "Broader imports, either all names or arbitrary code" alternative, which dives into the related tradeoffs a little more.
proposals/p0107.md
Outdated
is out of scope. | ||
|
||
- Name lookup, including addressing conflicting names between imports and | ||
names in the current file: Name lookup is likely to address this better, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
names in the current file: Name lookup is likely to address this better, | |
names in the current file: A separate name lookup proposal will address this directly, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I prefer "is likely to" because "will ... directly" sounds like a really firm statement about the future, one which I don't think I'm going to be responsible for enforcing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The most important word I wanted to include was "proposal" after "name lookup". Otherwise this sentence doesn't make sense.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, clarified "name lookup design".
Co-authored-by: josh11b <josh11b@users.noreply.github.com>
…nmeow/carbon-lang into proposal-code-and-name-organi
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- API file paths will correspond to the library name. | ||
- The precise form of this correspondence is undetermined, but should | ||
be expected to be similar to a "Math/Algebra" library being in a | ||
"Math/Algebra.carbon" file path. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had thought we would want to use the exact API file's path? That is, include the .carbon
? But maybe not.
(I don't feel strongly about this either way, and don't think this is super important, mostly want us to be intentional in the choice)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should omit it -- however, that can always change in another, more targeted proposal. I do admit an assumption that we wouldn't want to repeat file extensions, if possible. This is particularly notable if we expect all impl files to be prefixed with the library name, e.g. "Math/Algebra.impl.carbon", "Math/Algebra.impl.MyDetail.carbon", at which point adding the ".carbon" to the library will end up obfuscating the path.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree it should be omitted, as it is just boilerplate noise. Including it will make it harder to support filesystems that use .
as a directory separator.
- The precise form of this correspondence is undetermined, but should | ||
be expected to be similar to a "Math/Algebra" library being in a | ||
"Math/Algebra.carbon" file path. | ||
- The package will not be used when considering the file path. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we mention that the API file path above is relative to some package-specific root? or not at all?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd argue for leaving that to be resolved later. I think "package-specific" could imply that each package has its own root, and I believe the discussion so far had been:
-
A package may have multiple roots, such as one for human-authored files and one for auto-generated files. This could also be multiplied by separating public and package-internal APIs.
-
A given root could arguably contain multiple packages, as was suggested for the Google use-case.
Thus the idea of making a quick remark about a package-specific root seems pretty limiting, and one that should be delayed for further proposals. I can particularly see how #2 may get arguments.
Approved on 2020-10-06. Approval announcement |
Per discussion, chandlerc said he doesn't see a need to review again
- [RFC](https://forums.carbon-lang.dev/t/rfc-code-and-name-organization/121) - [Decision request](https://forums.carbon-lang.dev/t/request-for-decision-code-and-name-organization/140) - [Examples doc](https://docs.google.com/document/d/1J8GX9uw5AxBz5Q22MLHJOfzLq4WJqKL-q1VwnKGHG-k/edit) - [Approval announcement](https://forums.carbon-lang.dev/t/accepted-code-and-name-organization-107/150) Files, packages, libraries, and imports for Carbon. Contributors: chandlerc, fowles, tkoeppe, zygoloid
Files, packages, libraries, and imports for Carbon.
Contributors: chandlerc, fowles, tkoeppe, zygoloid