-
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
An incomplete, early, and in-progress overview of the language design. #83
An incomplete, early, and in-progress overview of the language design. #83
Conversation
Move firebase support into a src directory. (#15)
This is basically a snapshot of an in-progress document, moved to markdown and prepared for sharing with the wider community. It isn't finished. It isn't even necessarily up to date with the latest thinking on any particular area. But I think it will make more sense to land it as essentially a collective WIP and let people iterate on any given section as those details get sorted out. Even in its current form, I think it still provides a starting point and gives people the feel of what this will look like. There are a number of document links lost in this conversion. I've carefully left a `TODO` in the document at each point to come back and add the appropriate link back to the document once the rest of the existing material is somewhere visible. These were all fairly easy to preserve as they primarily were links out to an entire document.
Update fork
Co-authored-by: Jon Meow <46229924+jonmeow@users.noreply.github.com> Co-authored-by: josh11b <josh11b@users.noreply.github.com>
All (the pull request submitter and all commit authors) CLAs are signed, but one or more commits were authored or co-authored by someone other than the pull request submitter. We need to confirm that all authors are ok with their commits being contributed to this project. Please have them confirm that by leaving a comment that contains only Note to project maintainer: There may be cases where the author cannot leave a comment, or the comment is not properly detected as consent. In those cases, you can manually confirm consent of the commit author(s), and set the ℹ️ Googlers: Go here for more info. |
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.
docs/design/README.md
Outdated
supported. | ||
- Line comments look like `// ...`. However, they are required to be the only | ||
non-whitespace on the line for readability. | ||
- Block comments begin with `//\{`, and end with `//\}`. The begin and end |
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.
Trying to guess at what you mean, rephrased the next sentence.
|
||
Carbon provides metaprogramming facilities that look similar to regular Carbon | ||
code. These are structured, and do not offer inclusion or arbitrary | ||
preprocessing of source text such as C/C++ does. |
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.
Yes, that's a related proposal. Note though, I'm generally not taking time to link to related proposals -- I think the right thing to do is to maybe mention them if needed elsewhere, but not in the actual design. Rather, it should be accepted that the design will evolve over time, and that the specific proposal to do that may change (e.g., due to evolving ideas, or changes in ownership like how I took this proposal from Chandler).
docs/design/README.md
Outdated
- `UpperCamelCase` for names of compile-time resolved constants, such that they | ||
can participate in the type system and type checking of the program. |
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.
Added.
docs/design/README.md
Outdated
Common types that we expect to be used universally will be provided for every | ||
file, including `Int` and `Bool`. These will likely be defined in a `Carbon` | ||
package, and be treated as if always imported and aliased by every file. |
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.
Removed Carbon
name.
docs/design/README.md
Outdated
- Bitwise: `2 & 3`, `2 | 4`, `3 ^ 1`, `~7` | ||
- Bit sequence: `1 << 3`, `8 >> 1` | ||
- Comparison: `2 == 2`, `3 != 4`, `5 < 6`, `7 > 6`, `8 <= 8`, `8 >= 8` | ||
- Logical: `a && b`, `c || d` |
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.
Checking with @zygoloid for a second opinion; I'd actually thought the leaning was the stated way. Of course, this is a fairly minor point and can always be swapped later if proposals change.
docs/design/tuples.md
Outdated
### Indices as compile-time constants | ||
|
||
In the example `t1[2, 1, 0]`, we will likely want to restrict these indices to | ||
compile-time constants. Without that, run-time indexing would need to suddenly | ||
switch to a variant-style return type to handle heterogeneous tuples. This would | ||
both be surprising and complex for little or no value. |
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.
Moved
docs/design/tuples.md
Outdated
### Multiple indices | ||
|
||
In the example `t1[2, 1, 0]`, using multiple indices in this way is a bit | ||
questionable. If we end up wanting to support multidimensional arrays / slices | ||
(a likely selling point for the scientific world), a sequence of indices seems a | ||
likely desired facility there. We'd either need to find a different syntax | ||
there, change this syntax, or cope with tuples and arrays having different | ||
semantics for multiple indices (which seems really bad). |
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.
Just removing this (if the final design wants to talk about this more, that's fine)
docs/design/types.md
Outdated
# TODO | ||
|
||
<!-- | ||
Part of the Carbon Language project, under the Apache License v2.0 with LLVM | ||
Exceptions. See /LICENSE for license information. | ||
SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
--> | ||
|
||
## Table of contents | ||
|
||
<!-- toc --> | ||
|
||
- [TODO](#todo) | ||
- [Overview](#overview) | ||
|
||
<!-- tocstop --> | ||
|
||
## TODO | ||
|
||
This is a skeletal design, added to support [the overview](README.md). It should | ||
not be treated as accepted by the core team; rather, it is a placeholder until | ||
we have more time to examine this detail. Please feel welcome to rewrite and | ||
update as appropriate. | ||
|
||
## Overview |
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.
My mistake, removed
docs/design/variables.md
Outdated
### Declaring constants | ||
|
||
An open question is what syntax (and mechanism) to use for declaring constants. | ||
There are serious problems with the use of `const` in C++ as part of the type | ||
system, so alternatives to pseudo-types (type qualifiers) are being explored. | ||
The obvious syntax is `let` from Swift, although there are some questions around | ||
how intuitive it is for this to introduce a constant. Another candidate is `val` | ||
from Kotlin. Another thing we need to contend with is the surprise of const and | ||
reference (semantic) types. |
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.
Done, adjusted the argument for alternatives.
docs/design/README.md
Outdated
- All source code is UTF-8 encoded text. For simplicity, no other encoding is | ||
supported. | ||
- Line comments look like `// ...`. However, they are required to be the only | ||
non-whitespace on the line for readability. |
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.
It makes me sad to not have the ability to write:
var Int: x = foo; // This is a variable declaration
I'm not sure I understand the rationale here.
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.
@chandlerc I think this is from you. I personally agree with Bryce here.
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 believe this reflects the current proposal of #17. Rather than injecting a personal opinion on this issue, I think that:
- This can be resolved on the syntax-specific proposal, given there are differing opinions about the issue.
- If we start allowing examples to use
<code> // <comment>
, that's more expensive to fix later if the decision is to not allow that syntax than if we assume it will not be allowed and change our minds later.
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 commented there: #17 (comment)
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 I could remove all end-of-line comments from my codbase, I'd be real happy. Because under maintenance, lines often get longer. Some codebases have max-column limits. And when you have to automatically re-wrap as a result, there aren't good options.
docs/design/README.md
Outdated
- Block comments begin with `//\{`, and end with `//\}`. The begin and end | ||
markers must be the only things on their lines. |
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.
- Block comments begin with `//\{`, and end with `//\}`. The begin and end | |
markers must be the only things on their lines. | |
- Block comments begin with a line starting with `//\{`, and end with a line starting with `//\}`. |
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.
My concern is this is difficult to read. Rewrote this a little, and gave an example.
docs/design/README.md
Outdated
- All source code is UTF-8 encoded text. For simplicity, no other encoding is | ||
supported. | ||
- Line comments look like `// ...`. However, they are required to be the only | ||
non-whitespace on the line for readability. |
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.
@chandlerc I think this is from you. I personally agree with Bryce here.
docs/design/README.md
Outdated
- Block comments begin with `//\{`, and end with `//\}`. They are always at the | ||
start of a line. |
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.
- Block comments begin with `//\{`, and end with `//\}`. They are always at the | |
start of a line. | |
- Block comments begin with a line starting with `//\{`, and end with a line starting with `//\}`. |
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.
"begin with a line starting with" phrasing is a little confusing to me.
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.
As I understand @zygoloid 's lexing proposal, there may be additional characters on the line that starts with //\{
or //\}
, as in:
//\{ disabled
This is disabled
//\} disabled
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.
Rewritten with example
|
||
Carbon provides metaprogramming facilities that look similar to regular Carbon | ||
code. These are structured, and do not offer inclusion or arbitrary | ||
preprocessing of source text such as C/C++ does. |
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.
In 4 other cases you linked to the PR, I'm not sure what is different here.
docs/design/README.md
Outdated
modifying other types. They also have semantics that are defined from first | ||
principles rather than in terms of other operations. Even though these are | ||
special, their names are not keywords or reserved; they are just names in the | ||
global scope. |
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.
Here is an example of using the phrase "global scope". I think this is consistent with how that term is used in other in-progress design docs.
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.
Rewrote as prelude
docs/design/README.md
Outdated
- `Baz()` is invoked if `x` is greater than `77`. | ||
- Nothing happens if `x` is between `42` and `77`. | ||
|
||
#### `loop`, `break`, and `continue` |
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 replace loop
with while
in this section. There is no reason to be different from what people expect here.
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.
Done
docs/design/README.md
Outdated
|
||
Common types that we expect to be used universally will be provided for every | ||
file, including `Int` and `Bool`. These will likely be defined in a special | ||
"prelude" package which is treated as if always imported and aliased by every |
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 don't know what "imported and aliased" means. I think this might be another place where it would be clearer to explain that the prelude (and only the prelude) populates the global namespace.
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.
Removed
docs/design/naming_conventions.md
Outdated
- `UpperCamelCase` for names of compile-time resolved constants, such that they | ||
can participate in the type system and type checking of the program. |
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.
See revised correction.
docs/design/primitive_types.md
Outdated
modifying other types. They also have semantics that are defined from first | ||
principles rather than in terms of other operations. Even though these are | ||
special, their names are not keywords or reserved; they are just names in the | ||
implicit "prelude" that is imported and aliased into all files. |
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.
Again I don't think "imported and aliased" is clear.
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.
Copy-pasted new text from readme
docs/design/README.md
Outdated
- All source code is UTF-8 encoded text. For simplicity, no other encoding is | ||
supported. | ||
- Line comments look like `// ...`. However, they are required to be the only | ||
non-whitespace on the line for readability. |
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 commented there: #17 (comment)
@josh11b I started accepting changes, and then I realized I shouldn't because the decision is already underway. I can't make any more edits without an explicit decision from the core team. I agree the wording could be improved, but in the future, could you please consider filing an issue, plan out a follow-up PR for changes, or state explicit edits as a condition for your approval? This came up before with the goals PR, where I filed #106, but it's difficult to respond appropriately. |
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.
Comment pass; may need to take a closer look for unresponded comments
docs/design/README.md
Outdated
- Block comments begin with `//\{`, and end with `//\}`. The begin and end | ||
markers must be the only things on their lines. |
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.
My concern is this is difficult to read. Rewrote this a little, and gave an example.
docs/design/README.md
Outdated
- `UpperCamelCase` for names of compile-time resolved constants, such that they | ||
can participate in the type system and type checking of the program. |
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.
Thank you for suggesting a fix! I hadn't understood your criticism, so the positive example really helps.
docs/design/README.md
Outdated
- `Baz()` is invoked if `x` is greater than `77`. | ||
- Nothing happens if `x` is between `42` and `77`. | ||
|
||
#### `loop`, `break`, and `continue` |
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.
Done
docs/design/README.md
Outdated
modifying other types. They also have semantics that are defined from first | ||
principles rather than in terms of other operations. Even though these are | ||
special, their names are not keywords or reserved; they are just names in the | ||
global scope. |
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.
Rewrote as prelude
> **TODO:** References need to be evolved. | ||
|
||
User-defined types may have template parameters. The resulting type-function may | ||
be used to instantiate the parameterized definition with the provided arguments |
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'll need to switch terminology if we substantively change the meaning of "instantiate" -- it's too well known a term. As-is, I think either the templates proposal or the proposed glossary would be better places to define terminology.
> | ||
> **TODO:** References need to be evolved. | ||
|
||
Both implicit and explicit function parameters in Carbon can be marked as |
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 was looking at rewriting this, but nothing was popping out for me. For now, I'd rather rely on existing knowledge of implicit/explicit.
docs/design/naming_conventions.md
Outdated
- `UpperCamelCase` for names of compile-time resolved constants, such that they | ||
can participate in the type system and type checking of the program. |
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.
Accepted, thanks.
docs/design/primitive_types.md
Outdated
modifying other types. They also have semantics that are defined from first | ||
principles rather than in terms of other operations. Even though these are | ||
special, their names are not keywords or reserved; they are just names in the | ||
implicit "prelude" that is imported and aliased into all files. |
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.
Copy-pasted new text from readme
docs/design/README.md
Outdated
- Block comments begin with `//\{`, and end with `//\}`. They are always at the | ||
start of a line. |
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.
Rewritten with example
The main comment on a review wasn't being handled, and this change interleaves it with the PR comments. GitHub treats these as different entities. I'm hiding reviews with no top-level comment; these didn't seem worth including empty comments. Links are being added to PR comments to make them easier to find. This means indenting the content, so now all comments (PR or review thread) are consistently indented, removing a parameter. Also, I'm adjusting the formatting of review threads to match. snippets for comparison: ``` #83 (comment) googlebot: All (the pull request submitter and all commit authors) CLAs are... #83 (review) chandlerc: Overall, I think this is a pretty significant improved direction... ``` and from a review thread: ``` https://github.com/carbon-language/carbon-lang/pull/83/files/9863da8#diff-8f28081abb21e65fba5a0b0b29404c78R16 - line 16; unresolved - diff: https://github.com/carbon-language/carbon-lang/pull/83/files/9863da8..HEAD#diff-8f28081abb21e65fba5a0b0b29404c78L16 josh11b: ```suggestion¶ - Block comments begin with a line starting with `/... jonmeow: "begin with a line starting with" phrasing is a little confusing t... josh11b: As I understand @zygoloid 's lexing proposal, there may be additio... jonmeow: Rewritten with example ```
- [RFC topic](https://forums.carbon-lang.dev/t/rfc-add-idiomatic-code-performance-and-developer-facing-docs-to-goals/105) - [Decision](https://forums.carbon-lang.dev/t/request-for-decision-add-idiomatic-code-performance-and-developer-facing-docs-to-goals/116) Co-authored-by: Chandler Carruth <chandlerc@gmail.com> Co-authored-by: Geoff Romer <gromer@google.com> Co-authored-by: Dmitri Gribenko <gribozavr@gmail.com> Most of this is addressing issue #106. Two new explicit sub-goals: - Idiomatic code should be performant, stemming from #106. - User-facing documentation, separate thought from #83 discussion. I think both of these are on people's minds and assumed, but still worth spelling out.
- [RFC topic](https://forums.carbon-lang.dev/t/rfc-add-idiomatic-code-performance-and-developer-facing-docs-to-goals/105) - [Decision](https://forums.carbon-lang.dev/t/request-for-decision-add-idiomatic-code-performance-and-developer-facing-docs-to-goals/116) Co-authored-by: Chandler Carruth <chandlerc@gmail.com> Co-authored-by: Geoff Romer <gromer@google.com> Co-authored-by: Dmitri Gribenko <gribozavr@gmail.com> Most of this is addressing issue #106. Two new explicit sub-goals: - Idiomatic code should be performant, stemming from #106. - User-facing documentation, separate thought from #83 discussion. I think both of these are on people's minds and assumed, but still worth spelling out.
Co-authored by: chandlerc
This proposal should be considered a starting point of the language design. It's not intended to be final; language details may change. This is intended to offer a reasonable starting point for:
This proposal is not intended to achieve:
more carefully regardless. If you're passionate about a feature, please feel
free to start a new proposal for it.
examination and justification before it becomes a settled plan of record.
Chandler started this with #22. I've taken it over with the following changes:
For an example of how we may proceed with feature-specific designs, see #80. In this structure:
Simple designs may not have a subdirectory. All current feature-specific designs do not -- they may be moved later.