-
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
Structure, scope, and naming of the prelude and syntax aliases #2113
Comments
Comment to collect reactions for the package name specifically |
Comment to collect reactions for the package name specifically |
Comment to collect reactions for the package name specifically |
Comment to collect reactions for the package name specifically |
My preference is actually multiple packages are imported automatically by the prelude, each of which has a more-specific name: |
Hmmm, what would these packages contain? What would they not contain? Where would |
|
Where would |
I would put it in |
What about |
It surprises me a bit that we'd have multiple packages in the standard library, since it seems to contravene the rule of thumb that one git repo is one package. It also risks creating annoying taxonomy problems where we have to classify every library into exactly one package. That said, if we are going to have multiple packages, it seems like a very appealing simplification to have one package that contains all of the prelude, and only the prelude. I can imagine that not working out, but it seems worth a try. I think we shouldn't have the prelude boundary cut across package boundaries without a very compelling reason, because it will be harder to teach. |
After taking some time to think about it, I'm not really opposed to splitting up even the language-supporting stuff into finer grained packages. But I'm not sure it adds a lot of value and so I'm left a bit ambivalent. One specific observation:
I wonder if there is a bitter name for this specific case? |
Routines? Doesn't abbreviate well though. |
What about |
"Init" sounds a lot more like it is about initialization.
… What about Init? It sounds just like Prelude, but shorter. And unlike Core
and Base it tells exactly what's happening - it's the very beginning.
|
On #2360 it's suggested that this issue will decide the design of
|
Just wanted to say that the leads have gone through this in a reasonable amount of detail and we're all happy with the direction here, so closing this as decided. Specifically:
We'll definitely need a proposal to update and fully define the design of the prelude here, but this should allow other proposals and provisional things (like the provisional parts of the design overview and examples that have never been through a proposal) to update their plans and code to reflect this. I'll file a specific tracking issue to get the prelude itself defined and the core design updated.
After some discussion, this issue should not pick a specific spelling for any of these or say how they work. If we have a keyword though, it should be all lowercase. If it is going to alias something in the prelude, that should be But either #2360 or some other proposal or issue should sort out the exact spelling and how it is defined. I'll update #2360 with some of the thoughts that came up in the discussion of this aspect.
Tried to update title to be a bit more encompassing. =] Hopefully its better, but we should also have a pretty clear proposal that hammers this out in the design too. |
Also make minor updates to the skeletal design in docs/design/name_lookup.md following carbon-language#2113, as there are no longer any prelude names that are made available to unqualified name lookup by default. Add `type` to the keyword list in docs/design/lexical_conventions/words.md, following carbon-language#2360.
Short version: we should pick a scheme for naming things in the prelude of Carbon, and to a limited extent in the standard library more generally as they overlap. I'm suggesting the rough following scheme:
bool
,i32
, and so on.foo
might refer toSomePackageName.Foo
.This raises two more questions: what package names should the Carbon standard library use? (Or at least, the parts of the standard library we need to consider to establish what is in or not-in the prelude?) And how much of the standard library should be imported by the prelude?
For the first, after a bunch of thought, I'm being persuaded that Carbon's standard library shouldn't try to live in a single package, and the package names should -- to the extent possible -- be tied to the purpose or utility provided by that part of the standard library.
For example (but not suggested in this issue):
Math
package for things like the definition of π.Containers
package maybe for ... well ... containersI'd like to suggest that to start with, the only part of the standard library we put in the prelude are the parts of the standard library that are directly connected to the language itself: things like
bool
as that's the return type ofand
operators, all other types with dedicated syntax (i32
, etc), and interfaces used by language syntax likeCommonType
andAdd
.Note that these wouldn't get any preferential syntax by being in the prelude with this suggestion, just be available without any explicit import.
My suggestion is that we have a single package that is only the constructs that directly interact with the syntax in some way as part of the prelude to start. We can expand this in the future if desired, but I think its a safe place to start. I think its reasonable for all of those constructs to be in one package, and the fact that they're part of the language itself helps suggest how to name that package. Some options seem especially appealing to me:
Core
, as in interacting with the core language.Base
, as in the base of the library dependency graph.Language
, due to being part of the language.Prelude
, as it is the contents of the prelude.Of these, I like the idea of (c) best but I think it is a bit long. I like (a) more than (b), but that seems potentially just an aesthetic preference and not really based on anything. I'm not a huge fan of (d) because I worry about tying ourselves to never having other package names in the prelude.
So the net of this issue suggests that the prelude be an import of the
Core
package, and nothing else, for now.This package should at least contain:
bool
,iN
,uN
,fN
, pointer types, (potentially) array types, and any other types that have dedicated syntax or language construct affordances like pattern matching.CommonType
stuff,Add
, etc.)Print
function used when debugging code written in the language.Assert
function, whenever we have a design for one, as it will likely be used by any contract or invariant language features added.The package should not contain:
How do folks feel about this approach? (Marking it as an issue for leads to eventually resolve.)
The text was updated successfully, but these errors were encountered: