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

An incomplete, early, and in-progress overview of the language design. #83

Merged
merged 70 commits into from
Jul 30, 2020
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
Show all changes
70 commits
Select commit Hold shift + click to select a range
2ae6b6f
Merge pull request #1 from carbon-language/master
jonmeow May 20, 2020
5bba3a8
Merge remote-tracking branch 'upstream/master'
jonmeow May 20, 2020
98562a6
Merge remote-tracking branch 'upstream/master'
jonmeow May 21, 2020
7cd79ae
An incomplete, early, and in-progress overview of the language design.
chandlerc May 21, 2020
a05e9c3
Merge pull request #2 from carbon-language/master
jonmeow Jun 1, 2020
dfe42cb
Merge pull request #3 from carbon-language/master
jonmeow Jun 3, 2020
3931951
Merge pull request #4 from carbon-language/master
jonmeow Jun 4, 2020
fbbc0a8
Merge branch 'master' into lang-design-overview
chandlerc Jun 10, 2020
f2d0fcf
Extensive updates based on review feedback.
chandlerc Jun 10, 2020
6be32d3
Apply suggestions from code review
chandlerc Jun 10, 2020
3c13624
More tweaks
chandlerc Jun 10, 2020
43cfde9
Merge pull request #5 from carbon-language/master
jonmeow Jun 10, 2020
b489c23
Merge pull request #6 from carbon-language/master
jonmeow Jun 12, 2020
5b10b4d
Merge pull request #7 from carbon-language/master
jonmeow Jun 12, 2020
6ce0f97
Merge remote-tracking branch 'upstream/master'
jonmeow Jun 16, 2020
0132532
Proposal adjustments
jonmeow Jun 17, 2020
5209564
Merge branch 'master' into proposal-design-overview
jonmeow Jun 17, 2020
e72cf68
toc
jonmeow Jun 17, 2020
2ec94a9
Evolving structure
jonmeow Jun 17, 2020
2d69118
Delete the old doc
jonmeow Jun 17, 2020
e220190
Trying different format
jonmeow Jun 17, 2020
68b4e9b
Progress
jonmeow Jun 17, 2020
4b0a788
Progress
jonmeow Jun 17, 2020
4f83e44
Progress
jonmeow Jun 17, 2020
45cfaab
Progress
jonmeow Jun 17, 2020
39f0147
Progress
jonmeow Jun 17, 2020
34bb96d
Progress
jonmeow Jun 18, 2020
5d39a54
Progress
jonmeow Jun 18, 2020
3361b92
Progress
jonmeow Jun 18, 2020
0264743
Progress
jonmeow Jun 18, 2020
ea0f8e5
Progress
jonmeow Jun 19, 2020
25437de
Progress
jonmeow Jun 19, 2020
218df9f
Merge remote-tracking branch 'upstream/master'
jonmeow Jun 22, 2020
473055a
Update docs/design/name_lookup.md
jonmeow Jun 22, 2020
9058c25
Update docs/design/functions.md
jonmeow Jun 22, 2020
b464996
Update docs/design/functions.md
jonmeow Jun 22, 2020
1bb22b3
Update docs/design/structs.md
jonmeow Jun 22, 2020
5463882
Update docs/design/structs.md
jonmeow Jun 22, 2020
06a4f07
Update docs/design/structs.md
jonmeow Jun 22, 2020
13ec30b
No overview alternative
jonmeow Jun 22, 2020
f082a0d
Merge branch 'proposal-design-overview' of https://github.com/jonmeow…
jonmeow Jun 22, 2020
66fe610
No overview alternative
jonmeow Jun 22, 2020
96033db
<->
jonmeow Jun 22, 2020
6e9feb7
Remove ??? for alias
jonmeow Jun 22, 2020
c4c7c92
Update docs/design/README.md
jonmeow Jun 22, 2020
212f5ea
Apply suggestions from code review
jonmeow Jun 22, 2020
3655b59
Let loops be conditional
jonmeow Jun 22, 2020
56874f5
Fix
jonmeow Jun 22, 2020
a646508
Merge branch 'proposal-design-overview' of https://github.com/jonmeow…
jonmeow Jun 22, 2020
3420293
Applying suggestions
jonmeow Jun 22, 2020
18bc50f
codespell
jonmeow Jun 22, 2020
5c33fbf
Merge remote-tracking branch 'upstream/master'
jonmeow Jun 22, 2020
f64aa7b
Merge branch 'master' into proposal-design-overview
jonmeow Jun 22, 2020
97da855
Syntactic conventions
jonmeow Jun 22, 2020
33425d9
Addressing comments
jonmeow Jun 23, 2020
9ce1bfc
Add examples
jonmeow Jun 2, 2020
4412a88
Add examples
jonmeow Jun 2, 2020
555fe93
Update docs/design/templates.md
jonmeow Jul 1, 2020
848b37c
Merge branch 'proposal-design-overview' of https://github.com/jonmeow…
jonmeow Jul 1, 2020
fc5c103
Precommits
jonmeow Jun 2, 2020
0b113ce
Add tuple ambiguity question
jonmeow Jul 9, 2020
e95da90
Apply suggestions from code review
jonmeow Jul 10, 2020
9863da8
Addressing comments
jonmeow Jul 10, 2020
4809730
Link PR 89
jonmeow Jul 20, 2020
504c971
Merge branch 'trunk' into proposal-design-overview
jonmeow Jul 27, 2020
ddfc5f7
Update formatting
jonmeow Jul 27, 2020
7610342
Addressing comments
jonmeow Jul 28, 2020
6c25f8a
carbon marker
jonmeow Jul 28, 2020
1d9a660
Merge branch 'trunk' into proposal-design-overview
jonmeow Jul 30, 2020
d4550e3
Rename interop per #114
jonmeow Jul 30, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
378 changes: 193 additions & 185 deletions docs/design/README.md

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions docs/design/aliases.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

<!-- toc -->

- [TODO](#todo)
- [Overview](#overview)
- [Alternatives](#alternatives)
- [TODO](#todo)
- [Overview](#overview)
- [Alternatives](#alternatives)

<!-- tocstop -->

Expand Down
4 changes: 2 additions & 2 deletions docs/design/blocks_and_statements.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

<!-- toc -->

- [TODO](#todo)
- [Overview](#overview)
- [TODO](#todo)
- [Overview](#overview)

<!-- tocstop -->

Expand Down
12 changes: 6 additions & 6 deletions docs/design/control_flow.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

<!-- toc -->

- [TODO](#todo)
- [Overview](#overview)
- [Open questions](#open-questions)
- [`if` blocks](#if-blocks)
- [`break` and `continue`](#break-and-continue)
- [TODO](#todo)
- [Overview](#overview)
- [Open questions](#open-questions)
- [`if` blocks](#if-blocks)
- [`break` and `continue`](#break-and-continue)

<!-- tocstop -->

Expand Down Expand Up @@ -50,7 +50,7 @@ fn Foo(Int: x) {
}
```

Loops will at least be supported with a low-level primitive `loop` statement,
Loops will at least be supported with a low-level primitive `while` statement,
with `break` and `continue` statements which work the same as in C++.

Last but not least, for the basics we need to include the `return` statement.
Expand Down
18 changes: 9 additions & 9 deletions docs/design/files_libraries_and_packages.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

<!-- toc -->

- [TODO](#todo)
- [Alternatives](#alternatives)
- [File extensions](#file-extensions)
- [TODO](#todo)
- [Alternatives](#alternatives)
- [File extensions](#file-extensions)

<!-- tocstop -->

Expand All @@ -31,12 +31,12 @@ The use of `6c` as a short file extension or top-level CLI (with subcommands
below it similar to `git` or `go`) has some drawbacks. There are several other
possible extensions / commands:

- `cb`: This collides with several acronyms and may not be especially memorable
as referring to Carbon.
- `c6`: This seems a weird incorrect ordering of the atomic number and has a bad
(if _extremely_ obscure) Internet slang association (NSFW, use caution if
searching, as with too much Internet slang).
- `carbon`: This is an obvious and unsurprising choice, but also quite long.
- `cb`: This collides with several acronyms and may not be especially
memorable as referring to Carbon.
- `c6`: This seems a weird incorrect ordering of the atomic number and has a
bad (if _extremely_ obscure) Internet slang association (NSFW, use caution
if searching, as with too much Internet slang).
- `carbon`: This is an obvious and unsurprising choice, but also quite long.

This seems fairly easy for us to change as we go along, but we should at some
point do a formal proposal to gather other options and let the core team try to
Expand Down
4 changes: 2 additions & 2 deletions docs/design/functions.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

<!-- toc -->

- [TODO](#todo)
- [Basic functions](#basic-functions)
- [TODO](#todo)
- [Basic functions](#basic-functions)

<!-- tocstop -->

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Carbon ↔ C/C++ interoperability
# Bidirectional interoperability with C/C++

<!--
Part of the Carbon Language project, under the Apache License v2.0 with LLVM
Expand All @@ -10,8 +10,8 @@ SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

<!-- toc -->

- [TODO](#todo)
- [Overview](#overview)
- [TODO](#todo)
- [Overview](#overview)

<!-- tocstop -->

Expand Down
2 changes: 1 addition & 1 deletion docs/design/lexical_conventions.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

<!-- toc -->

- [TODO](#todo)
- [TODO](#todo)

<!-- tocstop -->

Expand Down
8 changes: 6 additions & 2 deletions docs/design/metaprogramming.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

<!-- toc -->

- [TODO](#todo)
- [Overview](#overview)
- [TODO](#todo)
- [Overview](#overview)

<!-- tocstop -->

Expand All @@ -22,6 +22,10 @@ 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.

See
[carbon-proposals PR 89](https://github.com/carbon-language/carbon-proposals/pull/89)
for context -- that proposal may replace this.

## Overview

Carbon provides metaprogramming facilities that look similar to regular Carbon
Expand Down
27 changes: 14 additions & 13 deletions docs/design/name_lookup.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

<!-- toc -->

- [TODO](#todo)
- [Overview](#overview)
- [Unqualified name lookup](#unqualified-name-lookup)
- [Alternatives](#alternatives)
- [Name lookup for common, standard types](#name-lookup-for-common-standard-types)
- [Open questions](#open-questions)
- [Shadowing](#shadowing)
- [TODO](#todo)
- [Overview](#overview)
- [Unqualified name lookup](#unqualified-name-lookup)
- [Alternatives](#alternatives)
- [Name lookup for common, standard types](#name-lookup-for-common-standard-types)
- [Open questions](#open-questions)
- [Shadowing](#shadowing)

<!-- tocstop -->

Expand Down Expand Up @@ -75,12 +75,13 @@ the package scope for unqualified name lookup.
### Name lookup for common, standard types

The Carbon standard library is in the `Carbon` package. A very small subset of
this standard library is provided implicitly in every file's scope as-if it were
first imported and then every name in it aliased into that file's package scope.
This makes the names from this part of the standard library nearly the same as
keywords, and so it is expected to be extremely small but contain the very
fundamentals that essentially every file of Carbon code will need (`Int`,
`Bool`, etc.).
this standard library is provided implicitly in every file's scope. This is
called the "prelude" package.

Names in the prelude package will be available without scoping names. For
example, `Bool` will be the commonly used name in code, even though the
underlying type may be `Carbon::Bool`. Also, no `import` will be necessary to
use `Bool`.

## Open questions

Expand Down
19 changes: 10 additions & 9 deletions docs/design/naming_conventions.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

<!-- toc -->

- [TODO](#todo)
- [Overview](#overview)
- [TODO](#todo)
- [Overview](#overview)

<!-- tocstop -->

Expand All @@ -34,13 +34,14 @@ Our current proposed naming convention, which we at least are attempting to
follow within Carbon documentation in order to keep code samples as consistent
as possible, is:

- `UpperCamelCase` for names of compile-time resolved constants, such that they
can participate in the type system and type checking of the program.
Comple-time constants fall into two categories:
- _Template_ constants that can be used in type checking, including literals.
- _Generic_ constants whose value is not used in type checking, but will be
used as part of code generation.
- `lower_snake_case` for names of run-time resolved values.
- `UpperCamelCase` for names of compile-time resolved constants, such that
they can participate in the type system and type checking of the program.
Comple-time constants fall into two categories:
- _Template_ constants that can be used in type checking, including
literals.
- _Generic_ constants whose value is not used in type checking, but will
be used as part of code generation.
- `lower_snake_case` for names of run-time resolved values.

As an example, an integer that is a compile-time constant sufficient to use in
the construction a compile-time array size might be named `N`, where an integer
Expand Down
2 changes: 1 addition & 1 deletion docs/design/operators.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

<!-- toc -->

- [TODO](#todo)
- [TODO](#todo)

<!-- tocstop -->

Expand Down
34 changes: 17 additions & 17 deletions docs/design/pattern_matching.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

<!-- toc -->

- [TODO](#todo)
- [Overview](#overview)
- [Pattern match control flow](#pattern-match-control-flow)
- [Pattern matching in local variables](#pattern-matching-in-local-variables)
- [Open questions](#open-questions)
- [Slice or array nested value pattern matching](#slice-or-array-nested-value-pattern-matching)
- [Generic/template pattern matching](#generictemplate-pattern-matching)
- [Pattern matching as function overload resolution](#pattern-matching-as-function-overload-resolution)
- [TODO](#todo)
- [Overview](#overview)
- [Pattern match control flow](#pattern-match-control-flow)
- [Pattern matching in local variables](#pattern-matching-in-local-variables)
- [Open questions](#open-questions)
- [Slice or array nested value pattern matching](#slice-or-array-nested-value-pattern-matching)
- [Generic/template pattern matching](#generictemplate-pattern-matching)
- [Pattern matching as function overload resolution](#pattern-matching-as-function-overload-resolution)

<!-- tocstop -->

Expand Down Expand Up @@ -75,15 +75,15 @@ introduced by the `if` keyword. The value pattern has to match, and then the
predicate has to evaluate to true for the overall pattern to match. Value
patterns can be composed of the following:

- An expression (`42` for example), whose value must be equal to match.
- An optional type (`Int` for example), followed by a `:` and either an
identifier to bind to the value or the special identifier `_` to discard the
value once matched.
- A destructuring pattern containing a sequence of value patterns
(`(Float: x, Float: y)`) which match against tuples and tuple like values by
recursively matching on their elements.
- An unwrapping pattern containing a nested value pattern which matches against
a variant or variant-like value by unwrapping it.
- An expression (`42` for example), whose value must be equal to match.
- An optional type (`Int` for example), followed by a `:` and either an
identifier to bind to the value or the special identifier `_` to discard the
value once matched.
- A destructuring pattern containing a sequence of value patterns
(`(Float: x, Float: y)`) which match against tuples and tuple like values by
recursively matching on their elements.
- An unwrapping pattern containing a nested value pattern which matches
against a variant or variant-like value by unwrapping it.

In order to match a value, whatever is specified in the pattern must match.
Using `auto` for a type will always match, making `auto: _` the wildcard
Expand Down
49 changes: 26 additions & 23 deletions docs/design/primitive_types.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,16 @@ SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

<!-- toc -->

- [TODO](#todo)
- [Overview](#overview)
- [Integers](#integers)
- [Floats](#floats)
- [BFloat16](#bfloat16)
- [Open questions](#open-questions)
- [Primitive types as code vs built-in](#primitive-types-as-code-vs-built-in)
- [String view vs owning string](#string-view-vs-owning-string)
- [Syntax for wrapping operations](#syntax-for-wrapping-operations)
- [Non-power-of-two sizes](#non-power-of-two-sizes)
- [TODO](#todo)
- [Overview](#overview)
- [Integers](#integers)
- [Floats](#floats)
- [BFloat16](#bfloat16)
- [Open questions](#open-questions)
- [Primitive types as code vs built-in](#primitive-types-as-code-vs-built-in)
- [String view vs owning string](#string-view-vs-owning-string)
- [Syntax for wrapping operations](#syntax-for-wrapping-operations)
- [Non-power-of-two sizes](#non-power-of-two-sizes)

<!-- tocstop -->

Expand All @@ -34,19 +34,22 @@ update as appropriate.

These types are fundamental to the language as they aren't either formed from or
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.

They in turn can be decomposed into the following categories:

- A monotype `Void` (or possibly `()`, the empty tuple) that has only one
possible value (empty).
- A boolean type `Bool` that has two possible values: `True` and `False`.
- Integer types
- Floating point types
- A string view type which is a read-only reference to a sequence of bytes
typically representing (UTF-8 encoded) text.
principles rather than in terms of other operations. These will be made
available through the [prelude package](README.md#name-lookup-for-common-types).

- `Void` - a type with only one possible value: empty.
- `Bool` - a boolean type with two possible values: `True` and `False`.
- `Int` and `UInt` - signed and unsigned 64-bit integer types.
- Standard sizes are available, both signed and unsigned, including
`Int8`, `Int16`, `Int32`, `Int128`, and `Int256`.
- Overflow in either direction is an error.
- `Float64` - a floating point type with semantics based on IEEE-754.
- Standard sizes are available, including `Float16`, `Float32`, and
`Float128`.
- [`BFloat16`](primitive_types.md#bfloat16) is also provided.
- `String` - a byte sequence treated as containing UTF-8 encoded text.
- `StringView` - a read-only reference to a byte sequence treated as
containing UTF-8 encoded text.

### Integers

Expand Down
18 changes: 9 additions & 9 deletions docs/design/structs.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

<!-- toc -->

- [TODO](#todo)
- [Overview](#overview)
- [Open questions](#open-questions)
- [`self` type](#self-type)
- [Default access control level](#default-access-control-level)
- [TODO](#todo)
- [Overview](#overview)
- [Open questions](#open-questions)
- [`self` type](#self-type)
- [Default access control level](#default-access-control-level)

<!-- tocstop -->

Expand Down Expand Up @@ -84,10 +84,10 @@ the type.

Some things in C++ are notably absent or orthogonally handled:

- No need for `static` functions, they simply don't take an initial `self`
parameter.
- No `static` variables because there are no global variables. Instead, can have
scoped constants.
- No need for `static` functions, they simply don't take an initial `self`
parameter.
- No `static` variables because there are no global variables. Instead, can
have scoped constants.

## Open questions

Expand Down
8 changes: 4 additions & 4 deletions docs/design/syntactic_conventions.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

<!-- toc -->

- [TODO](#todo)
- [Overview](#overview)
- [Alternatives](#alternatives)
- [Types before or after name](#types-before-or-after-name)
- [TODO](#todo)
- [Overview](#overview)
- [Alternatives](#alternatives)
- [Types before or after name](#types-before-or-after-name)

<!-- tocstop -->

Expand Down
Loading