-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
New Syntax for Capture Variables and Explicit Capture Polymorphism #22758
base: main
Are you sure you want to change the base?
Conversation
Just rebased on latest main |
After some deliberation, it's better to put the Note: since declared parameters can depend on subsequent parameters, there is no loss in expressivity, e.g., we can still support Applications: However, in argument positions need to disambiguate between structural types and refinement types, as well as object We drop the convenience that singletons do not require braces. TODO: make example file with various syntax ideas. |
[skip community_build]
Closes #22490
Builds on #22725
This aim of this PR is reducing the clunkyness of the explicit capture polymorphism syntax following internal discussions.
[cap B, A <: {B,x,y,z} ]
.Morally, capture variables are both terms and types (analogy: companion objects).
We might still in the future support uninterrupted curried lists of explicit capture-set parameters.
^
symbol for capture variables.cap C <: x
is the same ascap C <: {x}
.cap
members and parameters cannot be higher-kinded, i.e., they take no type-level parameters.cap
members and parameters may have context bounds, like ordinary type parameters.cap
parameter lists in higher-kinded types.using
for context parameters, we permit applying explicit capture sets withcap
(assumefoo
's signature from above):are currently not planned, but may be supported in the futureand named capture arguments coincidentally "just work":Standard type inference applies to other type parameters (such as
T
andX
offoo
).Extended syntax of capture set bounds (maybe, not planned now).
def foo3[cap A, B, C <: A & B] = ???
def foo4[cap A, B, C <: A | B]
, since we can always use the set notation{A,B}
.Rebase on Separation checking for product types #22539 and patch all tests.
Document the parser changes for capture checking in the internal
syntax.md
.Add specialized syntax error messages for cap lists & co.
Remove the old
[C^]
syntax for good.Make cap members and lists pretty-printed (with option to turn off).
Let parser mark capture variables with some attachment to be used by later phases.