Skip to content

Conversation

josh11b
Copy link
Contributor

@josh11b josh11b commented Aug 26, 2025

Introduces a new principle called "the signature is the contract," where Carbon requires the information needed to use an entity is present in the entity's declaration (its "signature"). The signature is authoritative, and is not modified by the definition body.

@josh11b josh11b added proposal A proposal proposal draft Proposal in draft, not ready for review labels Aug 26, 2025
@josh11b josh11b changed the title Principle: the signature is the contract Principle: The signature is the contract Aug 28, 2025
@josh11b josh11b marked this pull request as ready for review August 28, 2025 22:16
@github-actions github-actions bot added proposal rfc Proposal with request-for-comment sent out and removed proposal draft Proposal in draft, not ready for review labels Aug 28, 2025
@github-actions github-actions bot requested a review from KateGregory August 28, 2025 22:16
@github-actions github-actions bot added the documentation An issue or proposed change to our documentation label Aug 28, 2025
@@ -0,0 +1,119 @@
# Principle: The signature is the contract
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moving a Discord discussion here: I find this name quite opaque and non-mnemonic, to the extent that when revisiting the topic after only a few days, I had to skim this PR again to remind myself what the principle is actually about. I'd suggest instead something like "the signature is self-contained" or "the definition doesn't affect the signature".

To me, "the contract" refers to things like preconditions and postconditions (more broadly, everything that you need to reason about whether the calling code is correct), whereas "the signature" refers to the language-semantic content of a function declaration (i.e. everything that you need to reason about whether the calling code is well-typed). So "the signature is the contract" sounds to me like it's saying that Carbon will have statically-checked contracts as a language feature, and even suggests that we're trying to fully embed program correctness into the typesystem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation An issue or proposed change to our documentation proposal rfc Proposal with request-for-comment sent out proposal A proposal
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants