-
Notifications
You must be signed in to change notification settings - Fork 164
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
Surfacing External References #16
Comments
I like the I think the signature of promote needs to be a little different: promote(self: imm, region: mut) : (T & mut) | (None & imm) {...} Note the |
I agree with your changes. I had spotted the @sylvanc proposed giving it a Pony style partial function/exception like type: promote(self: imm, region: mut) : (T & mut) throws NotIn Then you could use a Pony-style try
{
var x = e.promote(r);
...
} This naturally leads into the design of exceptions, and how to make interesting DSL like accessors. |
So @sylvanc's actual proposal for the client was try (var x = e.promote(r))
{
C1
} Where this doesn't catch exceptions in I think we could surface the |
I actually think this can be done with just a builtin: merge[class T](x: T & iso, into: mut): T & mut
where return in into |
Motivation
Strict region ownership makes it impossible to do some efficient representations. Although, regions allow a doubly linked list to be expressed, that is actually insufficient for the common pattern of using a doubly linked list. Typically, you keep a reference to the Node to allow O(1) removal, but due to strict region ownership, that limits the applicability, and does not allow that reference to be across any concurrency boundary, e.g. in different cowns.
The runtime supports a concept of external reference that allows for a safe cross cown reference. The concurrency is safe as promotion back to the original reference requires a reference to the owning region, and thus cannot be promoted unless you already have access to the object's region.
Proposal
Here is a proposed API surface we could use to expose external region references:
The core motivating example for external references is doubly linked notification lists.
The client of the notification center does something like:
Alternative
Is it better to surface this as a class with a static and an instance method. Or should this be more primitively exposed in the type system to allow for better flow typing? At the moment, this would require a
match
on the result, would the following be better:This is a more complex change. Proposal to stick to exposing as API until we have experience with using?
Pre-requisites.
The raw API can be exposed directly without any additional work.
The full example requires region merge to be exposed in the language as well.
Notes
The run time has a unit test for this functionality.
The text was updated successfully, but these errors were encountered: