-
Notifications
You must be signed in to change notification settings - Fork 424
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
Dyno: implement manage statements & context managers #26494
Conversation
639ba96
to
25bae67
Compare
Signed-off-by: Danila Fedorin <[email protected]>
Signed-off-by: Danila Fedorin <[email protected]>
…ated. Signed-off-by: Danila Fedorin <[email protected]>
Signed-off-by: Danila Fedorin <[email protected]>
Signed-off-by: Danila Fedorin <[email protected]>
Signed-off-by: Danila Fedorin <[email protected]>
Signed-off-by: Danila Fedorin <[email protected]>
Signed-off-by: Danila Fedorin <[email protected]>
Signed-off-by: Danila Fedorin <[email protected]>
Previously, we didn't correctly find them during Dyno scope resolution, and later the production scope resolver took care of them. However, now that we find them, we have to note them as converted symbols so that when a toId points at an 'as' Variable, we know what to point the SymExpr to. Signed-off-by: Danila Fedorin <[email protected]>
Signed-off-by: Danila Fedorin <[email protected]>
Signed-off-by: Danila Fedorin <[email protected]>
Signed-off-by: Danila Fedorin <[email protected]>
Signed-off-by: Danila Fedorin <[email protected]>
Signed-off-by: Danila Fedorin <[email protected]>
Signed-off-by: Danila Fedorin <[email protected]>
Signed-off-by: Danila Fedorin <[email protected]>
Signed-off-by: Danila Fedorin <[email protected]>
Signed-off-by: Danila Fedorin <[email protected]>
Signed-off-by: Danila Fedorin <[email protected]>
Signed-off-by: Danila Fedorin <[email protected]>
Signed-off-by: Danila Fedorin <[email protected]>
25bae67
to
a2e2745
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The manage
technote and "manage statement" docs should be updated to reflect support for return intent overloading.
Also curious, what's the origin of the term 'witness' in this context?
Return intent overloading existed prior to my PR (I’m merely mimicking production) — I can add a follow-up to check the docs, but I don’t think my PR made any changes to the semantics of manage statements on that front.
Logic! For propositions like exists x, P(x), the “x” (or abusively, the whole combination of x and a proof of P(x)) is called a witness. In fact, interface search in general is “merely” a proof search in first order logic. You can think of each interface as a predicate (N-ary where N is the number of formals), and each This analogy typically comes from functional languages whose typeclasses are much like our interfaces. C.f. Haskell's typeclasses, Coq's typeclasses and Agda's instance arguments |
Signed-off-by: Danila Fedorin <[email protected]>
5c8d6ce
to
2623fd2
Compare
Oh right, we're in dyno lol. All good then.
Thanks for the explanation! I do remember that use of the term "witness" now, and the rest of it is new to me. |
Signed-off-by: Danila Fedorin <[email protected]>
Signed-off-by: Danila Fedorin <[email protected]>
Signed-off-by: Danila Fedorin <[email protected]>
Nice! |
This PR adds support for context managers:
It does so by leaning on interface support, since we have decided to use them to "bless" the special methods
enterContext
andexitContext
. As such, this PR depends on #26396 and #26471.The diff without the interface implementations can be found here: https://github.com/chapel-lang/chapel/pull/26494/files/8c4102910462ff3e792bddaa75e01bdbf1b2ee63..a2e2745e3d47a65c284fb8119660288f028bbaa4
The general approach is straightforward: since we can compute witnesses for special interfaces like
contextManager
, this PR ensures thatmanage
statements find thecontextManager
interface, and then use the witness functions as associated actions. Some complications arise due to the fact that context managers are design right now must be able to resolve return-intent-overloaded functions atmanage
time, which means (if the witness approach is to be used) that witnesses must contain all overloads. This PR adjusts for that, but only stores the additional overloads whenifc any return intent
(the pragma that decoratesenterContext
) is used, thus attempting to avoid paying the multi-overload cost for other interfaces and functions.Reviewed by @riftEmber -- thanks!
Testing