Skip to content

Conversation

@odersky
Copy link
Contributor

@odersky odersky commented Jan 8, 2026

  • Internally rename FreshCap to LocalCap

  • Introduce fresh

    • New global definition: caps.fresh.
    • fresh is for ResultCaps in function types.
    • Disallow fresh outside result types of function types.
  • Fix isTrackableRef: previously, a static term ref was trackable if its prefix was the ThisType
    of a package, but was not trackable if the prefix was a TermRef to the same package.
    Now both versions are trackable.

  • Don't go to basetypes when comparing dependent functions at cc

  • Improve printing of capabilities:

    • Don't elide a universal capture set in a TypeMismatch message if one of its capabilities is mentioned
      in an error note.
    • Don't elide capture sets containing fresh when printing
    • Don't use the verbose output for fresh if there are no open existentials
    • Systematically backquote all entities shown as capabilities

@odersky odersky changed the title Internally rename FreshCap to AnyCap Internally rename FreshCap to LocalCap Jan 9, 2026
@odersky odersky requested a review from a team as a code owner January 9, 2026 12:53
@odersky odersky changed the title Internally rename FreshCap to LocalCap Rename caps.cap to caps.any Jan 9, 2026
@odersky odersky force-pushed the rename-cap branch 5 times, most recently from a78d005 to 1c34c9f Compare January 14, 2026 14:59
@SethTisue
Copy link
Member

(fyi @nrinaudo, who iirc might have suggested the name change?)

@bracevac
Copy link
Contributor

@bjornregnell

@odersky
Copy link
Contributor Author

odersky commented Jan 15, 2026

any was a result of a discussion with @bjornregnell. The first suggestion was anyCapability but then we felt it safe to abbreviate to just any. any can only used in capture sets such as C^{any}, so it's clear from the context that it is a capability.

@bjornregnell
Copy link
Contributor

bjornregnell commented Jan 15, 2026

Yes, I think any is much less cryptic and unabiguous than cap and says what it is more directly. I observed in the talks about capabilities that the speakers always had to phrase an explanation of cap in terms of a "root" capability or similar that actually refers to any capability so I think this is a great improvement.

@nrinaudo
Copy link

Oh thank god, I had no recollection of suggesting this and was wondering if my mind was finally starting to go.

@nrinaudo
Copy link

Yes, I think any is much less cryptic and unabiguous than cap and says what it is more directly. I observed in the talks about capabilities that the speakers always had to phrase an explanation of cap in terms of a "root" capability or similar that actually refers to any capability so I think this is a great improvement.

This might not be the place for this question, feel free to let me know if it's not, but: how is that going to interact with there being multiple root capabilities? Are we going to have error messages like any^1 and any^2 refer to any capabilities, but not necessarily the same ?

@bjornregnell
Copy link
Contributor

Oh thank god, I had no recollection of suggesting this and was wondering if my mind was finally starting to go.

I'm the guilty one :)

BTW: many thanks for your efforts in providing pedagogical and down-to-earth explanations of the practical usage of capabilities and capture checking! @nrinaudo

@nrinaudo
Copy link

BTW: many thanks for your efforts in providing pedagogical and down-to-earth explanations of the practical usage of capabilities and capture checking! @nrinaudo

Yeah well now I have to go and fix all of them to use any rather than cap, don't I? :)

You're quite welcome - it's mostly how I learn, by explaining things to others and exposing holes in my understanding that I need to fix.

@bjornregnell
Copy link
Contributor

bjornregnell commented Jan 15, 2026

Yes, I think any is much less cryptic and unabiguous than cap and says what it is more directly. I observed in the talks about capabilities that the speakers always had to phrase an explanation of cap in terms of a "root" capability or similar that actually refers to any capability so I think this is a great improvement.

This might not be the place for this question, feel free to let me know if it's not, but: how is that going to interact with there being multiple root capabilities? Are we going to have error messages like any^1 and any^2 refer to any capabilities, but not necessarily the same ?

I guess, esp. for improving error messages etc there needs to be a way to talk about different subsets of any. Helping the user of capture checking to understand the implications of the checking rules via error messages is really important, but can also be challenging as the theory includes concepts that may seem esoteric to a beginner. Any suggestions on good feedback from the compiler in diagnostics, errors and warnings is helpful.

@odersky odersky force-pushed the rename-cap branch 2 times, most recently from ceb4e2d to a48b37b Compare January 15, 2026 16:28
@odersky
Copy link
Contributor Author

odersky commented Jan 15, 2026

I guess, esp. for improving error messages etc there needs to be a way to talk about different subsets of any. Helping the user of capture checking to understand the implications of the checking rules via error messages is really important, but can also be challenging as the theory includes concepts that may seem esoteric to a beginner. Any suggestions on good feedback from the compiler in diagnostics, errors and warnings is helpful.

What we do now:

  • If there are several any or fresh occurrences to different capabilities, they get subscripts.
  • We have a "where" clause that explains what these capabilities are and where they come from.
  • We avoid referring to the same capability in different ways. I.e. if we have A => B and a separate note that mentions the any to which => expands, we avoid A => B and print A ->{any} B instead.

Also, LocalCaps are no longer described as "fresh" in error messages.
 - Introduce `fresh`

    - New global definition: `caps.fresh`.
    - `fresh` is for ResultCaps in function types.
    - Disallow `fresh` outside result types of function types.

 - Fix isTrackableRef: previously, a static term ref was trackable if its prefix was the ThisType
   of a package, but was not trackable if the prefix was a TermRef to the same package.
   Now both versions are trackable.

 - Don't go to basetypes when comparing dependent functions at cc

 - Improve printing of capabilities:

    - Don't elide a universal capture set in a TypeMismatch message if one of its capabilities is mentioned
      in an error note.
    - Don't elide capture sets containing fresh when printing
    - Don't use the verbose output for fresh if there are no open existentials
    - Systematically backquote all entities shown as capabilities
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants