-
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
Naming conventions for Carbon-provided features #750
Comments
My preferred option:
Just a collection of my thoughts on the various points you raised:
|
Wouldn't that make |
I would make |
Looks like we have consensus on my suggested pattern in #750 (comment). Some terminology that came up in discussion:
And last but not least, to emphasize: pre-declared identifiers (and the package name of the prelude library) are available with unqualified lookup, but the same names can still be declared (shadowing), and then accessed with qualified namelookup to disambiguate:
Whereas, whenever the name is |
Addressed by #861 |
The most significant change here is that explorer now uses the chosen spelling rather than the old `Bool` spelling. Also update a few documentation examples and some skeletal design docs to use the chosen spelling.
What naming conventions should be used for Carbon-provided features?
Where I think we have consensus:
for
,return
,break
, etc arelower_snake_case
.i32
naming per pick names for fixed-size integer types #543import Carbon
should follow naming conventions laid out at naming conventionsWhere I think there's not an established choice:
Bool
/bool
, orTrue
/true
, explicitly deferred by pick names for fixed-size integer types #543while
and other keywords can easily handle it.Self
/self
andSuper
/super
String
/string
, would we writeIsEmpty
oris_empty
?I've come up with one easily summarized rule that's consistent with
i32
:import
is alwayslower_snake_case
.bool
,true
,self
,super
,string.is_empty()
bool
,true
,self
,super
,string.IsEmpty()
I have a couple that are inconsistent with
i32
, although numeric types could be special-cased:lower_snake_case
Bool
/bool
,True
/true
is implementation-dependentself
,super
(because they can't be in prelude)String.IsEmpty()
lower_snake_case
, everything else uses standard naming conventionsBool
/bool
,True
/true
is implementation-dependentSelf
,Super
(assuming they work as class-scoped aliases, unless we consider them keywords)String.IsEmpty()
There's of course always the option of saying that non-keyword names are rare and can be decided on a case-by-case basis; we don't need a standard naming convention.
Thoughts?
I don't think this is blocking things, but it'd be nice to have it resolved as these are going to be put into a lot of early code/docs/examples, by their nature.
The text was updated successfully, but these errors were encountered: