Commit Graph
226 Commits
Author SHA1 Message Date
907be6465f Functions, function types, and function calls (#2875)
Specify the behavior of function calls and the type and behavior of the
entity
introduced by a function declaration.

---------

Co-authored-by: Jon Ross-Perkins <jperkins@google.com>
Co-authored-by: josh11b <josh11b@users.noreply.github.com>
Co-authored-by: Chandler Carruth <chandlerc@gmail.com>
2023-08-31 05:19:29 +00:00
josh11bandRichard Smith d5d6945f85 Update member_access.md to reflect accepted proposals (#3160)
Most changes are due to proposal #2360, but this also includes changes
to reflect: #1136, #2138, #2006, #2550, and #2964.

---------

Co-authored-by: Richard Smith <richard@metafoo.co.uk>
2023-08-31 00:17:00 +00:00
josh11b 9600030a05 Reduce ambiguity in terminology (#3162)
Change terminology away from terms that are ambiguous:

- Reserve "generic type" for types with (compile-time) parameters, like
`Vector` in `Vector(T:! type)`. Don't use that term to refer to `T`, as
it would with
[#2360](https://github.com/carbon-language/carbon-lang/blob/trunk/proposals/p2360.md#terminology).
- Use the term "compile-time" instead of "constant" to mean "template or
symbolic." Expand the term "constant" to include values, such as from
`let` bindings.
2023-08-30 17:13:40 +00:00
1d4e9ee1ea ranged-based for for user-defined types (#1885)
The goal of this proposal is to provide a way for user-defined types to
support range-based iteration with `for`.
The current proposed solution exposes 3 interfaces that can be
implemented by user types to enable support for
ranged-for loops.

Co-authored-by: josh11b <josh11b@users.noreply.github.com>

---------

Co-authored-by: josh11b <josh11b@users.noreply.github.com>
Co-authored-by: Jon Ross-Perkins <jperkins@google.com>
Co-authored-by: Geoff Romer <gromer@google.com>
Co-authored-by: Chandler Carruth <chandlerc@gmail.com>
2023-08-25 23:25:19 +00:00
Jon Ross-Perkins 605763d62d Add lint fixes to the buildifier setup. (#3109)
The main motivation for this is to get python loads in using the
`native-py` lint fix. However, enabling that made me wonder, maybe we
should fix in general?

`native-cc` is delayed, but not wholly cancelled (and `native-py`
picking up might indicate `native-cc` won't be too far behind). There's
also some automated fixes for `.append` and dict sorting -- this felt
okay to me, maybe not something to eagerly add but probably not worth
stopping buildifier from fixing (I've noticed the warnings in the past
and had been ignoring them).

Running everything does mean that load orders are sorted automatically
now, which I think is a positive. Most generally, I think these fixes
aren't _harmful_, and having them done automatically seems beneficial:
my biggest concern about `native-py` and `native-cc` was actually that
regressions wouldn't be caught, but this addresses that issue
automatically.
2023-08-22 21:01:42 +00:00
0d1e6bd84d Values, variables, pointers, and references (#2006)
Introduce a concrete design for how Carbon values, objects, storage,
variables,
and pointers will work. This includes fleshing out the design for:

- The expression categories used in Carbon to represent values and
objects,
how they interact, and terminology that anchors on their expression
nature.
-   An expression category model for readonly, abstract values that can
    efficiently support function inputs.
- A customization system for value expression representations,
especially as
    seen on function boundaries in the calling convention.
- An expression category model for references instead of a type system
model.
-   How patterns match different expression categories.
-   How initialization works in conjunction with function returns.
- Specific pointer syntax, semantics, and library customization
mechanisms.
- A `const` type qualifier for use when the value expression category
system
    is too abstracted from the underlying objects in storage.

---------

Co-authored-by: Geoff Romer <gromer@google.com>
Co-authored-by: josh11b <josh11b@users.noreply.github.com>
Co-authored-by: Adrien Leravat <Pixep@users.noreply.github.com>
Co-authored-by: Jon Ross-Perkins <jperkins@google.com>
Co-authored-by: Richard Smith <richard@metafoo.co.uk>
2023-08-08 07:27:44 +00:00
josh11b 916bb4022a Update generics goals doc (#3060)
This reflects changes from #2138 , plus a number of other updates,
including reflecting that we have decided to include templates in
Carbon.
2023-08-05 05:39:34 +00:00
587ab64d1b Update Generics terminology document (#3048)
This reflects changes from a number of approved proposals:
- #920 : concrete statements about orphan and overlap in Carbon
- #2138 : "generic" -> "checked generic", "template" -> "template
generic"
- #2188 : binding patterns are forbidden in type position
- #2360 : "type", "facet type", "facet". Note: I am not using the term
"generic type" from #2360 since that meaning conflicts with the
generally accepted meaning of "generic type" of a type with a
compile-time parameter.
- #2760 / #2770 : internal/external impl -> extending impl
- #2964 : "symbolic constant" and "template constant"

---------

Co-authored-by: Geoff Romer <gromer@google.com>
Co-authored-by: Richard Smith <richard@metafoo.co.uk>
2023-08-02 23:22:15 +00:00
ea982ad2c8 Simplified package declaration for the Main package (#2550)
Make the preamble of simple programs more ergonomic, by removing the
`package Main` from the main package and removing the `package`
declaration
entirely from the main source file. Imports within a single package no
longer
need to, and are not permitted to, specify the package name.

Partially covers #2001 / #1136.
Covers #1869.
Supersedes #2265.
Addresses design idea #2323.

---------

Co-authored-by: Jon Ross-Perkins <jperkins@google.com>
Co-authored-by: josh11b <josh11b@users.noreply.github.com>
2023-07-06 21:55:54 +00:00
josh11bandjonmeow e0e684067a Expression phase terminology (#2964)
Update terminology around expression properties:

-   "value phase" -> "expression phase"
-   "symbolic value" -> "symbolic constant"
-   "constant" -> "template constant"
-   "constant or symbolic value" -> "constant"

Implements the decision in #1391 .

---------

Co-authored-by: jonmeow <jperkins@google.com>
2023-07-06 21:45:09 +00:00
e8f0866b2f Introduce a new Conduct team (#2922)
The Carbon Project relied on the three leads to handle conduct concerns initially as it bootstrapped its community team and expertise. We now have an active and effective community lead and team of moderators. Our community lead has worked to train and ramp up a new and independent conduct team.

This proposal both provides an overview of the process and hands off conduct handling to the new team! Going forward, we expect routine updates to the conduct team to happen without full proposals as they allow trained folks to rotate in and out of this difficult but essential role on the project.

Last but not least, making these changes uncovered a restriction in the Code of
Conduct itself that we expect to be problematic to adhere to going forward.
While well intentioned, it has a bunch of unanticipated effects that made both
current and new conduct teams want to remove it. A related section has had its
wording strengthened to try and address the underlying motivation at least
partially.

Most of this content comes from @CelineausBerlin with some additions and edits from myself and the other leads as we worked toward building the new CoC team.

Co-authored-by: Céline Dedaj <CelineausBerlin@users.noreply.github.com>
Co-authored-by: Geoff Romer <gromer@google.com>
Co-authored-by: Kate Gregory <kate@Gregcons.com>
2023-06-27 15:35:35 -07:00
Jon Ross-Perkins 4619ffa874 Update pre-commit (#2919)
codespell correctly caught `failuers` now, but `ForIn` was a false positive. No other new issues raised.
2023-06-16 11:11:46 -07:00
766bb7ec58 Character Literals (#1934) (#1964)
Put character literals in single quotes, like `'a'`. Character literals work
like numeric literals:

-   Every different literal value has its own type.
-   The bit width is determined by the type of the variable the literal is
    assigned to, not the literal itself. Follows the plan from #1934.

Co-authored-by: Richard Smith <richard@metafoo.co.uk>
Co-authored-by: josh11b <josh11b@users.noreply.github.com>
Co-authored-by: Chandler Carruth <chandlerc@gmail.com>
2023-06-15 13:51:43 -07:00
josh11bandRichard Smith 6f8cf38329 Consistent class and interface syntax (#2760)
Update syntax of `class` and `interface` definitions to be more consistent. Constructs that add names to the class or interface from another definition are always prefixed by the `extend` keyword.

Implements the decisions in:

-   [#995: Generics external impl versus extends](https://github.com/carbon-language/carbon-lang/issues/995),
-   [#1159: adaptor versus adapter may be harder to spell than we'd like](https://github.com/carbon-language/carbon-lang/issues/1159),
-   [#2580: How should Carbon handle conditionally implemented internal interfaces](https://github.com/carbon-language/carbon-lang/issues/2580), and
-   [#2770: Terminology for internal and external implementations](https://github.com/carbon-language/carbon-lang/issues/2770).

Co-authored-by: Richard Smith <richard@metafoo.co.uk>
2023-06-14 17:18:54 -07:00
josh11b f0ead22f0c Allow overlap with a final impl if identical (#2868)
Allow an `impl` to overlap with a `final impl` if they agree on the overlap. Agreement is defined as all values comparing equal, and functions never comparing equal.  Implements the decision in question-for-leads issue #1077.
2023-06-02 16:05:46 -07:00
debe4cc151 Defining the 0.1 language (#2759)
Provide a clear definition of our goals for the 0.1 Carbon language, and a
concrete feature-set that is expected to satisfy these goals.

The high level goal proposed for the 0.1 language is to reach an evaluation-MVP
(Minimal Viable Product): it should be sufficiently complete to evaluate its
suitability specifically with respect to fitness as a C++ successor language.

The features proposed for 0.1 language in turn focus on C++ interoperability and
a minimal subset of foundational aspects of the language.

Beyond the language itself, the other project features and milestones proposed
focus on enabling evaluation of the language design and interoperating with C++
in practice.

Co-authored-by: Richard Smith <richard@metafoo.co.uk>
Co-authored-by: jonmeow <jperkins@google.com>
Co-authored-by: josh11b <josh11b@users.noreply.github.com>
2023-04-25 18:19:06 -07:00
31e907178f Termination algorithm for impl selection (#2687)
This proposal replaces the termination algorithm for `impl` selection. The previous algorithm relied on a recursion limit, which is counter to [our goal for predictability](/docs/design/generics/goals.md#predictability).

The replacement is to terminate if any `impl` declaration depends transitively on itself with a "strict superset" type as one of its parameters.

Co-authored-by: Richard Smith <richard@metafoo.co.uk>
Co-authored-by: Satakshi Garg <56358125+satakshigarg@users.noreply.github.com>
Co-authored-by: Chandler Carruth <chandlerc@gmail.com>
2023-04-10 13:15:07 -07:00
642fcd3b77 Replace keyword is with impls (#2483)
Use the keyword `impls` instead of `is` when writing a `where` constraint that a type variable needs to implement an interface or named constraint.

What was previously (provisionally) written:
```
fn Sort[T:! Container where .ElementType is Ordered](x: T*);
```
will now be written:
```
fn Sort[T:! Container where .ElementType impls Ordered](x: T*);
```

---------

Co-authored-by: Geoff Romer <gromer@google.com>
Co-authored-by: Chandler Carruth <chandlerc@gmail.com>
2023-03-22 21:45:32 -07:00
Jon Ross-Perkins 9a063ccdc5 Semicolons terminate statements (#2665)
Statements, declarations, and definitions will terminate with either a semicolon
(`;`) or a close curly brace (`}`). Semicolons are never optional.

For example, with a semicolon, `x = x + 2;`. With a close curly brace,
`for ( ... ) { ... }`, or `class C { ...}`.

This does not affect any approved proposal; rather, it makes an important
assumption explicit.

Based on lead decision #1924

Fixes #2002
2023-03-16 14:17:39 -07:00
Richard Smithandjosh11b 0b6411e6cc Associated constant assignment versus equality (#2173)
Split the `where A == B` constraint in two: `where .A = B` produces a new
constraint from an old one, where the value of `.A` in the new constraint is
known and eagerly rewritten to `B`, and `where A == B`, which does not cause
`A` and `B` to be considered as identical by language rules but does permit
implicit (no-op) conversion between them.
 
This aims to provide an efficiently-computable and human-understandable type
equality rule, with type canonicalization and therefore transitive type
equality, without sacrificing too much in the way of ergonomics and without
sacrificing determinism, while still providing the full power of a general type
constraint system in a less ergonomic form.

Co-authored-by: josh11b <josh11b@users.noreply.github.com>
2023-02-01 10:03:30 -08:00
a89aba2698 Assignment statements (#2511)
Assignment is permitted only as a complete statement, not as a subexpression.
Assignment and compound assignment syntax follow C++ in all other respects.
Pre-increment is provided. Post-increment is not. Uses of all of these operators
are translated into calls to interface members.

Co-authored-by: Jon Ross-Perkins <jperkins@google.com>
Co-authored-by: Chandler Carruth <chandlerc@gmail.com>
2023-01-27 19:03:47 -08:00
Chandler Carruth cad750c864 Finish an incomplete sentence in p2551. (#2554)
This was discussed in person with at least two of the leads while
drafting the text, but sadly it did not finish being typed into the
document.

Just amending the proposal text for the future as I don't think it
substantively changes the conclusions.

Thanks to @geoffromer for noticing this!
2023-01-24 16:08:41 -08:00
Chandler Carruth 9faf87e171 Roadmap for 2023 and retrospective for 2022 (#2551)
We propose a roadmap for 2023 focus on:

-   Progressing towards a concrete goal of an MVP / 0.1 language.
-   Engaging more broadly and deeply with the C++ community.

We also reflect on our overly ambitious
[roadmap for 2022](https://github.com/carbon-language/carbon-lang/blob/3d90a85f2439bb74b71a553c5017012369ec0f63/docs/project/roadmap.md)
and how the year went.
2023-01-24 15:44:39 -08:00
d70e237026 Pattern matching syntax and semantics (#2188)
This paper proposes concrete syntax and semantic choices for Carbon patterns.

Co-authored-by: josh11b <josh11b@users.noreply.github.com>
Co-authored-by: Geoff Romer <gromer@google.com>
Co-authored-by: David Sankel <camior@gmail.com>
2023-01-06 18:30:37 -08:00
16dcdc2a34 Types are values of type type (#2360)
Define a "type" to be a value of type `type`. Contexts expecting a type perform an implicit conversion to `type`. Values like `()` and `(i32, i32)` and `{}` are no longer types, but instead implicitly convert to `type`. Values of interface or constraint type (now called "facets") are similarly not formally types but implicitly convert to `type`.

Co-authored-by: Chandler Carruth <chandlerc@gmail.com>
Co-authored-by: josh11b <josh11b@users.noreply.github.com>
Co-authored-by: Jon Ross-Perkins <jperkins@google.com>
2022-12-22 13:49:55 -08:00
Geoff RomerandRichard Smith 44ba541f1f Update sum types design (#2187)
This proposal updates the design of [p0157](https://github.com/carbon-language/carbon-lang/blob/trunk/proposals/p0157.md) to reflect subsequent evolution of the language.

Resolves #1805 

Co-authored-by: Richard Smith <richard@metafoo.co.uk>
2022-12-12 14:08:05 -08:00
josh11b ee998c99ff Clean up some small mistakes (#2451) 2022-12-07 15:12:08 -08:00
josh11bandRichard Smith d1210c4a50 Rename me -> self (#1382)
Carbon has been using a `me: Self` or `addr me: Self*` deduced parameter to mark a function as a method as decided in #494 and implemented in #722 . This does not match existing languages, and so this proposal switches `me` to `self` to match Python, Rust, and Swift.

Co-authored-by: Richard Smith <richard@metafoo.co.uk>
2022-12-06 15:58:48 -08:00
josh11bandRichard Smith 571b869f1c Constraints must use Self (#2376)
Require `impl as` constraints in an `interface` or `constraint` definition to mention `Self` implicitly or explicitly. Require `where` clauses to refer to `.Self` directly, or through a designator like `.Foo`.

Co-authored-by: Richard Smith <richard@metafoo.co.uk>
2022-12-02 16:11:23 -08:00
c9a1e351ba Template generics (#2200)
Add template generics, with optional constraints but no [SFINAE](https://en.cppreference.com/w/cpp/language/sfinae), to Carbon. Template generics allows the compiler postpone type checking of expressions dependent on a template parameter until the function is called and the value of that parameter is known.

Example usage:

```carbon
fn Identity[template T:! Type](x: T) -> T {
  return x;
}
```

Co-authored-by: Richard Smith <richard@metafoo.co.uk>
Co-authored-by: Chandler Carruth <chandlerc@gmail.com>
2022-11-17 10:23:52 -08:00
Jon Ross-PerkinsandRichard Smith 14cc716ddc Allow unqualified name lookup for class members (#2287)
Allow unqualified name lookup in multiple situations:

-   For classes and interfaces, whether inside the class scope or within an
    out-of-line function definition.
-   For namespaces, when the namespace is used in a declaration.

Co-authored-by: Richard Smith <richard@metafoo.co.uk>
2022-11-09 14:34:30 -08:00
4885a2bf8e Subscript syntax and semantics (#2274)
Adds support for subscripting using the conventional square-bracket syntax, with support for both array-like and slice-like semantics.

Co-authored-by: Richard Smith <richard@metafoo.co.uk>
Co-authored-by: josh11b <josh11b@users.noreply.github.com>
2022-11-09 11:50:22 -08:00
josh11bandRichard Smith e29e4cfa29 What can be done with an incomplete interface (#2347)
Clarify what can and cannot be done with a incomplete interface or named constraint.

Co-authored-by: Richard Smith <richard@metafoo.co.uk>
2022-11-09 08:37:25 -08:00
Chandler Carruth 0478cbd9b3 Remove artificial version ceiling on C++ interop. (#2365)
Remove a confusing mention of a specific version of C++ (C++17) from the
interoperability goals.

Expand the content of the goals to make it clear that we have a moving and
ongoing target of C++ as it continues to evolve. Also emphasize that we will
prioritize among the different features during Carbon's development based on how
they impact the overall project.

However, this intends to preserve the fact that there may exist long-tail or
corner-case features in C++ that never end up with high quality or exhaustive
support in our interop story simply because their impact on Carbon users is
sufficiently small that it doesn't justify the cost.

Fixes #1587
2022-11-02 19:29:05 -07:00
Jon Ross-Perkins f1e36a50ca C/C++ -> C and C++ (#2340)
As requested at https://github.com/carbon-language/carbon-lang/pull/2332#discussion_r1002257672, "Very minor, but "C/C++" irritates some people in the C++ community so we may as well avoid it here."
2022-10-25 12:06:24 -07:00
Chandler CarruthandCéline Dedaj b315c69f0c Begin publishing CoC and moderation transparency reports. (#2295)
Provides a documented cadence, publishing target, and template for Code of Conduct and moderation transparency reports.

Based on the initial proposal draft from @CelineausBerlin.

Co-authored-by: Céline Dedaj <CelineausBerlin@users.noreply.github.com>
2022-10-18 10:59:08 -07:00
josh11b e941b90ac9 Correctly remove ## TODO section from proposals (#2207)
Fix bug introduced in #2139
2022-09-22 08:20:07 -07:00
Jon Ross-Perkins 1dcd15380c Remove stacked PR notes (#2205)
chandlerc had originally added these and previously expressed being okay with removing them. They've just proven too complex to be applied; it needs to be easier for people to want to do it.
2022-09-21 16:10:36 -07:00
Richard Smith ff1d69232b Switch proposal link text from pNNNN to #NN for consistency (#2202)
This is the only occurrence of using pNNNN in text to refer to a Carbon proposal in the repo. This gets us closer to following https://github.com/carbon-language/carbon-lang/blob/trunk/docs/project/design_style_guide.md.
2022-09-21 10:37:07 -07:00
b464a0ac3d Unused Pattern Bindings (Unused Function Parameters) (#2022)
This proposal specifies how unused pattern bindings are written in the Carbon programming language. This is a more general problem statement of "how do users specify unused function parameters" as function parameter declarations are a more specific form of pattern

Related issue #1996

Co-authored-by: Geoff Romer <gromer@google.com>
Co-authored-by: Richard Smith <richard@metafoo.co.uk>
2022-09-20 17:44:22 -07:00
josh11bandRichard Smith 83f1d29f3c Checked and template generic terminology (#2138)
Change terminology from "generics" and "templates" to "checked generics" and "template generics". Afterwards, "generics" will be an umbrella term that include templates.

Co-authored-by: Richard Smith <richard@metafoo.co.uk>
2022-09-09 21:15:46 -07:00
49c9732e8e Numeric type literal syntax (#2015)
This proposal aims to add a literal syntax for fixed-sized numeric types: integers, unsigned integers, and floating-point numbers.

Fixes #1998

Co-authored-by: josh11b <josh11b@users.noreply.github.com>
Co-authored-by: Richard Smith <richard@metafoo.co.uk>
2022-09-08 15:49:11 -07:00
josh11b e4595deb4b Clarify rules around Self and .Self (#2107)
A number of smaller changes grouped together in one proposal:

-   Make `Self` a keyword.
-   Clarify that `Self` refers to the current type in a base class and in impl declarations.
-   Clarify when `.Self` is legal, and what type it has.
-   Also specify that `where` is not an associative operator.
2022-09-08 13:04:58 -07:00
josh11b e489b14de0 Fix new_proposal.py to include "Abstract" section (#2139)
"Proposal" was hard-coded as the first section and so it was deleting the "Abstract" section along with the "TODO" section.
2022-09-01 14:21:04 -07:00
David Sankel 48ba8bf6b6 Are We Explorer Yet? (#1891)
It is currently difficult to see the status of Carbon explorer and where effort
is needed. We propose creating a AreWeYet-styled dashboard to address this.
2022-08-26 11:50:22 -07:00
David Sankel ea0a37dbf3 Add Abstract Section (#1895)
Reading through extensive problem and background documentation before seeing
what is being proposed is tedious for a reader. An abstract section at the
beginning of a document that provides a succinct summary helps a lot. We
propose adding such a section to our proposal template.
2022-08-26 11:49:25 -07:00
ba2cfc2d0d Weaken digit separator placement rules (#1983)
[Proposal #143: Numeric literals](https://github.com/carbon-language/carbon-lang/blob/trunk/proposals/p0143.md) added digit separators with strict rules for placement. It missed some use-cases. In order to address this, remove placement rules for numeric literals.

Related issue: #1485 

Co-authored-by: Chandler Carruth <chandlerc@gmail.com>
Co-authored-by: Richard Smith <richard@metafoo.co.uk>
2022-08-25 14:52:43 -07:00
07d6a03b32 Change raw string literal syntax: [#]*" represents single-line string and [#]*''' represents block string (#1360)
Use `"` for simple string literals and `'''` for block string literals.

Co-authored-by: Jon Ross-Perkins <jperkins@google.com>
Co-authored-by: Richard Smith <richard@metafoo.co.uk>
2022-08-25 14:04:22 -07:00
Jon Ross-Perkins 065d5224be Remove reviewer setting, let autoassign take over (#2094)
Fixes #1841

The current autoassign doesn't work, but I'm trying to fix it (e.g., #2093)
2022-08-23 12:13:41 -07:00
Jon Ross-Perkins 15d1e07133 Unicode char limit (#2040)
The `\u{HHHH...}` can be an arbitrary length, potentially including `\u{}`.
Restrict to 1 to 8 characters.
2022-08-16 09:41:52 -07:00