Commit Graph
133 Commits
Author SHA1 Message Date
Richard Smith 93a002a21a Avoid confusing description of "equivalent". (#843) 2021-10-06 11:06:34 -07:00
Richard Smith aec77a6f39 Add a keyword list. (#869)
This list was extracted from currently-approved proposals and
corresponding design documents. This is intended to be a summary of the
status quo, not a change.
2021-10-06 11:05:41 -07:00
Richard Smith 0539931b76 PR 866: Allow ties in floating literals. (#866) 2021-10-02 11:01:29 -07:00
Geoff RomerandChandler Carruth bf49f2efed Proposal: Property naming in C++ (#720)
This proposed style change allows C++ classes in the Carbon project to provide methods that are named like variables, so long as they behave like _properties_ of the class. It also requires data member names to have a trailing `_`.

Co-authored-by: Chandler Carruth <chandlerc@gmail.com>
2021-09-28 14:36:43 -07:00
Jon Meow 563201a849 Remove proposals/BUILD, moving template.md under scripts (#846)
With #842 there's not as much reason for the BUILD anymore, maybe move the template.md file and get rid of it?
2021-09-23 09:16:19 -07:00
f63169608e Implicit conversions (#820)
Proposal to support a limited set of implicit conversions.

This would generally permit only implicit conversions that are lossless and semantics-preserving. In particular, this proposal allows:

-   Conversion from an integer type to a wider integer type of the same signedness, and from an unsigned integer type to a wider signed integer type.
-   Conversion from an integer type to a floating-point type that has enough mantissa bits to exactly represent all integers in the source type.
-   Conversion from integer literals to integer and floating-point types that can represent them.
-   Conversion from floating-point literals to floating-point types that can represent them.
-   Conversions required for generics: conversions of values between facet types, and conversions of types between type-of-types, as described in the generics proposals.
-   Conversions required for inheritance: derived-to-base conversions for class pointers and class values.

Other conversions, such as lossy conversions between arithmetic types and conversions between bool and other types are not supported.

Co-authored-by: josh11b <josh11b@users.noreply.github.com>
Co-authored-by: Chandler Carruth <chandlerc@gmail.com>
Co-authored-by: Geoff Romer <gromer@google.com>
2021-09-21 15:16:16 -07:00
Jon MeowandChandler Carruth c3f4f28ec5 One way principle (#829)
Add a principle that Carbon should only provide one way of doing things

Co-authored-by: Chandler Carruth <chandlerc@gmail.com>
2021-09-21 09:45:35 -07:00
Jon MeowandChandler Carruth 6d33a80988 api file default public (#752)
Replace library public-like `api` behavior with explicit `private` behavior, mirroring #665 

Co-authored-by: Chandler Carruth <chandlerc@gmail.com>
2021-09-21 09:33:32 -07:00
Richard Smith 0fec34df03 Tiny doc update: var is not an expression. (#812) 2021-09-14 13:17:31 -07:00
3610325c38 Inheritance (#777)
This proposal adds inheritance to classes, following this syntax:
```
// Abstract classes may not be instantiated, but
// may have abstract methods and be extended.
abstract class AbstractBaseClass {
  virtual fn CanBeOverridden[me: Self]() -> i32 {
    return me.data;
  }
  abstract fn PureVirtual[me: Self]() -> i32;
  fn Create(data: i32) -> partial Self {
    return {.data = data};
  }
  protected var data: i32;
}

// Classes are final by default
class FinalClass extends AbstractBaseClass {
  impl fn PureVirtual[me: Self]() -> i32 {
    return me.x;
  }
  fn Create(data: i32) -> Self {
    return {.base = AbstractBaseClass.Create(data), .x = 2 * data};
  }
  private var x: i32;
}

// Can be instantiated and extended
base class ExtensibleClass {
  // May optionally use partial types in factory functions
  protected fn CreateAsBase(data: i32) -> partial Self { ... }
  fn Create(data: i32) -> Self { ... }
}
```

Co-authored-by: Chandler Carruth <chandlerc@gmail.com>
Co-authored-by: Richard Smith <richard@metafoo.co.uk>
2021-09-08 17:37:35 -07:00
225eda7f49 Generics details 2: adapters, associated types, parameterized interfaces (#731)
This proposal goes into the details for these features of generics:

- adapters: for creating new types compatible with existing types but with different interface implementations
- associated types: allowing an interface implementation to specify some types to use in method signatures
- interface parameters: creating a family of interfaces, where types can implement more than one

This is a continuation of #553 . It has been summarized in these presentations:

- adapters: [1](https://docs.google.com/presentation/d/1bg6q0Q9Sk4YpRbNA3D3H34xYtaEO8ScAUNUZK2UTi80/edit?resourcekey=0-6-Y6e1mfRUmHg-Zk65Gc5A#slide=id.gcf40df1c7b_0_37) and [2](https://docs.google.com/presentation/d/17KG0TeJ4OChMRdLJPS8TE_K6SoL4lFy1FUGr2CDzX-A/edit?resourcekey=0-kLnZqd5NrbGSwmbunTyB-A#slide=id.g7a37009490_0_0)
- [associated types and interface parameters](https://docs.google.com/presentation/d/19hPpUjxQ0H1lUSLy5QjS2910Cpc7UdNKpF580fFsCGw/edit?resourcekey=0-ky9XGRC1I8X0Ffw6eqh7WQ#slide=id.p)

Co-authored-by: Wolff Dobson <wolffg@users.noreply.github.com>
Co-authored-by: Richard Smith <richard@metafoo.co.uk>
2021-09-05 15:50:53 -07:00
Jon Meow eb61412c79 Explicitly disallow self-imports by libraries (#794) 2021-09-03 17:01:52 -07:00
Geoff Romer e08beccc66 Use "package directive" and "import directive" (#808)
These aren't really statements (because they're not executed at run time), and it's debatable whether they're declarations, since their primary purpose isn't to introduce a name. On Discord, "directive" seemed to be the consensus choice for an alternate term.
2021-09-03 11:54:41 -07:00
Jon Meow 49013ae1cc Reject invalid string literal whitespace on unescape (#793)
This is based on discussion on #732: that we should probably parse the invalid whitespace, then reject it as part of string validation, rather than having different parses. I worry the question of "how is this parsed" may lead to subtly unexpected results if we aren't consistent, so I'm switching the logic from the lexer to the unescape library (and also adjusting the list of rejected whitespace).
2021-08-30 15:22:03 -07:00
Jon MeowandRichard Smith 08c538af86 Update alternatives/references style in lexical conventions (#727)
Co-authored-by: Richard Smith <richard@metafoo.co.uk>
2021-08-27 15:47:02 -07:00
Jon MeowandRichard Smith 30682750ce Updated string literal design based on #199 (#732)
I've modified the text from the proposal slightly, focusing the overview more on a design setup, but mostly kept the details. One important thing here is I noticed that raw tab characters are disallowed -- this was a little buried before, and I've now updated the list of characters allowed in a string to exclude tabs. Additionally, I've noted `\0D` in the list of escapes as explicitly invalid.

Co-authored-by: Richard Smith <richard@metafoo.co.uk>
2021-08-27 15:43:14 -07:00
Chandler Carruth 821daa220a Adjust the evolution process based on experience. (#764)
Recent experience indicates that the system of thumbs-up doesn't seem to
work consistently. Replace it with more broad encouragement to use PR
reactions to surface sentiment and a judgement call by the leads on when
a proposal is ready to merge.

An explicit goal here is that leads can make this judgement call
reflecting the nature of the proposal. Many of these are low-risk.
Either they are easily fixed-forward or minimally disruptive. This can
be because they are merely beginning to fill out a largely open area, or
because they are minor changes.

Also try to clarify that it is expected for the leads to sometimes miss
things or make mistakes, and encourage a revert or fix-forward mentality
rather than slowing down progress to reduce the rate of mistakes.
2021-08-27 15:31:31 -07:00
Jon Meow d550256c93 Delete the website and references (#782)
.pre-commit-config.yaml and proposals/p0540.md (linking goals.html, fixed to goals.md link) are the two references I could find.

The site is disabled, though; I think it makes the most sense to delete supporting code, and in the future hopefully we can use GH pages to publish.
2021-08-25 14:15:01 -07:00
Jon MeowandChandler Carruth 5042d96863 Switch to a brew version of python3.9 (#778)
- brew instead of pyenv to centralize package management
  - can't recall why we used pyenv before, may not have been the best choice.
  - pyenv has been a burden in updating versions, a single `brew upgrade` works better
- python3.9 because it's the latest and greatest, feels weird going to old versions if we're recommending installs.
- bazel 5.0.0 pre-release due to https://github.com/bazelbuild/bazel/commit/b9fc66d327debcfbdb2964afdba35a1cc8919b81
  - earlier versions want `python` to be on the path, which pyenv did but brew does not

For most people this will mean: `rm -rf ~/.pyenv && brew uninstall pyenv && brew install python@3.9 && pip3 install -U pip && pip3 install pre-commit`, plus removing any `pyenv` invocations from the shell `rc` file.

Co-authored-by: Chandler Carruth <chandlerc@gmail.com>
2021-08-25 09:10:35 -07:00
josh11bandChandler Carruth 0820dec01f Nominal classes and methods (#722)
Add support for nominal (or "named") classes with encapsulation. Inheritance will be in a later proposal. Here is an example of the proposed syntax:

```
class Circle {
  fn Create(c: Point, r: f32) -> Self {
    return {.center = c, .radius = r};
  }
  fn Diameter[me: Self]() -> f32 {
    return me.radius * 2;
  }
  fn Expand[addr me: Self*](distance: f32);

  private var center: Point;
  private var radius: f32;
}

fn Circle.Expand[addr me: Self*](distance: f32) {
  me->radius += distance;
}
```

Co-authored-by: Chandler Carruth <chandlerc@gmail.com>
2021-08-23 15:45:41 -07:00
Jon Meow b73ad7dd1a Update references/alternatives in return doc (#730) 2021-08-17 08:35:02 -07:00
Jon Meow aebfa7dac9 Update alternatives/references style in variables (#728)
Moving "Global variables" out of "Alternatives"; I don't think it's really been considered in the same way that others have, so there's no reference to provide.
2021-08-12 08:31:35 -07:00
Jon MeowandRichard Smith 8d3d1b1233 Flesh out loops docs a little (#729)
Co-authored-by: Richard Smith <richard@metafoo.co.uk>
2021-08-12 08:20:46 -07:00
Jon Meow 6c5cf38879 Rewrite source file alternatives/references (#723) 2021-08-12 08:19:24 -07:00
Jon Meow c33994d1d1 Rewrite code and name organization alternatives/references (#724)
Alternatives just link to the proposal PR due to the legacy decision of putting alternatives in the doc.
2021-08-12 08:18:39 -07:00
josh11bandRichard Smith ecb5a611e5 Generics details part 1 (#553)
This proposal goes into the details of the core of the generics feature, to achieve the goals from #24 , and provides an outline covering future work. It has been summarized in these presentations:

- [basic usage](https://docs.google.com/presentation/d/1OZiMTVW2Ommop5WTs9RyEwnGxy9yzaAPF7Cj5KUfDsY/edit?resourcekey=0-Nya0Soz3ZNs3hJan8VIrTA#slide=id.p)
- [details: interfaces](https://docs.google.com/presentation/d/1FSlqtE5hXZIwOO52UrAK9DINBLDWtgu24dugHfomUMg/edit#slide=id.p)
- [details: facet types](https://docs.google.com/presentation/d/17KG0TeJ4OChMRdLJPS8TE_K6SoL4lFy1FUGr2CDzX-A/edit?resourcekey=0-kLnZqd5NrbGSwmbunTyB-A#slide=id.p)
- [details: type-types](https://docs.google.com/presentation/d/1Hn3VDlVjwhjx3SKM2KXKE7lW208nXff30x3-uIO4_Fo/edit#slide=id.p)
- [details: extending/refining interfaces](https://docs.google.com/presentation/d/1K0cCHeb9JTJY9QCGEVO9CcJNHYlaXkoPESv4J9tl5LU/edit#slide=id.p)

Co-authored-by: Richard Smith <richard@metafoo.co.uk>
2021-08-10 20:46:23 -07:00
Jon Meow 9168375978 Move interop reference link (#725) 2021-08-10 12:36:09 -07:00
Jon Meow e05225f90a Fix conditionals link style (#726) 2021-08-10 12:35:57 -07:00
36764ff1af Basic classes: use cases, struct literals, struct types, and future work (#561)
This proposal defines the very basics of `class` types, primarily focused on:

-   use cases including: data classes, encapsulated types, inheritance with and without `virtual`, interfaces as base classes, and mixins for code reuse;
-   anonymous data types for called _structural data classes_ or _struct types_. Struct literals are used to initialize class values and ad-hoc parameter and return types with named components; and
-   future work, including the provisional syntax already in use for features that have not been decided.

The intent is to both make some small incremental progress and get agreement on direction. As such it doesn't include things like nominal types, methods, access control, inheritance, etc.

It proposes this struct type and literal syntax:
```
var p: {.x: Int, .y: Int} = {.x = 0, .y = 1};
```
Note that it uses commas (`,`) between fields instead of semicolons (`;`), and no introducer for types or literal values.

Incorporates decisions from #665 , #653 , #651


Co-authored-by: Geoff Romer <gromer@google.com>
Co-authored-by: Chandler Carruth <chandlerc@gmail.com>
2021-08-09 12:28:36 -07:00
josh11bandRichard Smith 48b7dc3b81 :! generic syntax (#676)
This implements decision #565 to use `T:! Type` to declare generic parameters, and `template T:! Type` for template parameters.

Co-authored-by: Richard Smith <richard@metafoo.co.uk>
2021-08-04 14:27:11 -07:00
38eb2c0d2f Low context-sensitivity principle (#646)
Establish a principle that understanding the meaning and performance should not depend on expensive context, and explain what makes context expensive.

Co-authored-by: Chandler Carruth <chandlerc@gmail.com>
Co-authored-by: Jon Meow <46229924+jonmeow@users.noreply.github.com>
Co-authored-by: Richard Smith <richard@metafoo.co.uk>
2021-08-03 10:20:46 -07:00
Jon Meow 2f023b3479 Flesh out the conditionals doc (#655) 2021-07-29 15:31:36 -07:00
Jon Meow 61abc44aef Mention the RFC project column in docs (#688)
Nothing is automating "ready for review" unfortunately, but the lack of RFC mention seems like a clear miss.
2021-07-29 10:57:21 -07:00
a725ae214d Add design style guide and a description of what belongs in the design versus in a proposal document. (#649)
Expand the description of the structure of a proposal PR. Clarify that
the full PR is the proposal, not only the P-numbered document. Start a
design style guide and use it to describe which parts of a proposal
should not end up in the design.

Co-authored-by: Jon Meow <46229924+jonmeow@users.noreply.github.com>
Co-authored-by: Chandler Carruth <chandlerc@gmail.com>
2021-07-26 11:58:40 -07:00
e932b7dcc3 Draft return docs (#620)
Co-authored-by: Richard Smith <richard@metafoo.co.uk>
Co-authored-by: Chandler Carruth <chandlerc@gmail.com>
2021-07-16 10:29:09 -07:00
josh11b 9e1816f9c0 Update method syntax in generics overview (#634)
* Implement #494 for overview.md
2021-07-15 08:55:02 -07:00
Jeremy G. Siek 2f950d279f fix a forgotten flipping of the parameter name and type (#643) 2021-07-14 16:09:53 -04:00
josh11b ffcdaf9aff Update code syntax in generics terminology (#633)
Reflects #565 and #494
2021-07-09 13:03:40 -07:00
josh11b 88c8877ff9 Update code syntax in generics goals (#632) 2021-07-09 13:00:47 -07:00
199c7e365c var ordering (#618)
Propose the decision from #542, noting implementation from #563

Also integrates some of #339 into `variables.md` because that's actually how this started, looking for a proposal reference for #542 

Co-authored-by: Richard Smith <richard@metafoo.co.uk>
Co-authored-by: josh11b <josh11b@users.noreply.github.com>
2021-07-09 11:49:32 -07:00
josh11bandChandler Carruth d70297077b Update terminology in generics design docs (#610)
* implicit -> deduced
* type-type -> type-of-type
* extending/refining -> extending

Co-authored-by: Chandler Carruth <chandlerc@gmail.com>
2021-06-29 13:23:35 -07:00
978e27f484 Generics overview (#524)
This adds an overview of a generics feature that attempts to achieve the goals from #24 . It has been summarized in these presentations:

- [non-type params](https://docs.google.com/presentation/d/1IZaDxP5Y3Wqprkyjzagv48tyxEeIcfz8FZS3Namsvew/edit#slide=id.p)
- [basic usage](https://docs.google.com/presentation/d/1OZiMTVW2Ommop5WTs9RyEwnGxy9yzaAPF7Cj5KUfDsY/edit?resourcekey=0-Nya0Soz3ZNs3hJan8VIrTA#slide=id.p)
- [more advanced usage](https://docs.google.com/presentation/d/1bg6q0Q9Sk4YpRbNA3D3H34xYtaEO8ScAUNUZK2UTi80/edit?resourcekey=0-6-Y6e1mfRUmHg-Zk65Gc5A#slide=id.p)

Co-authored-by: Jon Meow <46229924+jonmeow@users.noreply.github.com>
Co-authored-by: Chandler Carruth <chandlerc@gmail.com>
Co-authored-by: Wolff Dobson <wolffg@users.noreply.github.com>
2021-06-29 10:52:45 -07:00
Geoff Romer d3b4358fd5 Update stacked pull request workflow. (#590)
This avoids having the stacked PR get auto-closed in step 7, and clarifies that you need to merge from trunk to the formerly-stacked PR in order to avoid spurious diffs.
2021-06-24 13:15:24 -07:00
Jon Meow 7af826e4df Update docs for pyenv and llvm (#570) 2021-06-10 08:32:15 -07:00
Chandler CarruthandJon Meow 05261b7fe7 Remove the LLVM bootstrap and use Hombrew installed LLVM-12. (#551)
Now that LLVM 12 has been released we no longer have any need to
bootstrap LLVM to get the desired featureset. LLVM 12 is available
widely, including in Homebrew across multiple platforms and in the
GitHub action runners.

Sadly, the Linux distribution builds of LLVM-12 are largely broken and
not as useful for us. The Homebrew Linux install was also broken
originally, but I've worked extensively with the Homebrew folks to get
the Linux install into a really good shape. It should now work reliably.

There are two primary bugs in Linux LLVM packages that need to be fixed
before we can just use them:

- https://bugs.llvm.org/show_bug.cgi?id=43604
- https://bugs.llvm.org/show_bug.cgi?id=46321

Once those are addressed and point releases with the fixes widely
available we can further simplify things.

Even with the need to use Homebrew installs, using the released LLVM has
the extra advantage of making it easy to properly support Darwin ARM and
I've added that configuration so that I can test things there.

Last but not least, this will significantly shrink our build outputs
which should allow building much more in continuous integration on
GitHub actions without exceeding the action cache size limits. I've even
added several tweaks and adjustments to the compile and build flags to
improve the build performance and reduce the build output size.

Once this is landed and stable, we can consider adding the refactoring
tooling back to our CI.

One of the biggest downsides of this path is that our CI has to download
and install the LLVM toolchain from Homebrew on each run. This is pretty
slow (takes a couple of minutes). But it is a fixed overhead -- it won't
get worse over time. Eventually, we can either look at a much fancier
action configuration to avoid this or hopefully the Debian packages will
get updated and we can move back to those.

The bootstrapping has served us long enough at this point. We can
resurrect it if we ever find a compelling reason for breaking off of the
latest LLVM release as our host toolchain.

Co-authored-by: Jon Meow <46229924+jonmeow@users.noreply.github.com>
2021-06-09 10:00:46 -07:00
Jon Meow 40f60e6591 Clean up vscode mentions and standardize install label (#569)
Also we don't use markdown-toc anymore.
2021-06-08 15:31:16 -07:00
josh11b c836ae78bb for uses in instead of :, and implement #542. (#563)
* `for` uses `in` instead of `:`, and implement #542.
2021-06-03 07:56:48 -07:00
josh11b 60fdda7aaf Update generics terminology to latest syntax (#560)
* Update generics terminology to latest syntax.
2021-06-03 07:54:44 -07:00
josh11b cf3c90ac3e Switch to name: type variable and parameter syntax in README.md. (#562) 2021-06-02 20:11:32 -07:00
Geoff Romer c903eb3133 Remove Void (#540)
Implements resolution of #443.
2021-06-01 12:48:04 -07:00