-
Notifications
You must be signed in to change notification settings - Fork 98
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
feat: allow access to Self
and its public methods from actor
initialisers
#4719
base: master
Are you sure you want to change the base?
Conversation
9c6ab4d
to
e2e0255
Compare
d8b1c69
to
8933498
Compare
Self
and its public methods from actor initialisersSelf
and its public methods from actor
initialisers
when both sides are external view -> structurally compare tuples when both internal -> physical equality (as before) when mixed -> fail for now
ca314eb
to
2eb4457
Compare
this is also how `ClassD` is done
resolves a FIXME
resolves a FIXME
(M.empty, S.singleton i.it) +++ delayify ( | ||
group msgs (dec_fields msgs dfs @ class_self d.at i') /// pat msgs p /// shared_pat msgs csp | ||
group msgs ~extern (dec_fields msgs dfs @ class_self d.at i' s.it) /// pat msgs p /// shared_pat msgs csp |
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.
Instead of adding the ~extern optional parameter, why not just add (class_self ... ) to beginning or end of the decs argument, depending on whether this is an actor
(at front) or at other object
(at end).
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.
(and then rename class_self to obj_self...)
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.
Well, that would break
$ cat test/run-drun/self-shadow.mo
actor foo {
public func foo() {};
flexible func go() : async () {
let bar = actor bar { public func bar() {} }
};
}
right? See also the discussion in #1104.
(* Insert the externally defined binding in front if present, non-shadowing *) | ||
let defWhen = match extern with | ||
| Some b when M.find_opt b.it defWhen |> Option.is_none -> M.add b.it (-1) defWhen | ||
| _ -> defWhen in |
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.
You might not need this if you just extend the decs appropriately,
let env' = adjoin_vals { env with self = self } ve_in in | ||
interpret_dec_fields env' dec_fields ve_ex | ||
let env'' = adjoin_vals { env' with self } ve_in in | ||
interpret_dec_fields env'' dec_fields ve_ex | ||
(fun obj -> | ||
(env.actor_env := V.Env.add self obj !(env.actor_env); |
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.
Crazy idea: At the moment, the actor environment maps actor ids to Objects containing a map from field names to values.
Suppose we changed that, so an actor environment just contains a map from field names to promises (i.e. ve_ex
).
Then we can update the actor map before we interpret the body. As the promises in ve_ex
get defined, so do the ones accessible from the self-reference, a bit like your previous 'increments' but automatic.
I think that might let us implement the equality on mixtures of symbolic and function references (provided we also give the equality operator) access to the environment.
Best attempted in a separate PR I think. Might be a dead-end with too many pervasive changes.
| Func _, Tup [Blob _; Text _] | ||
| Tup [Blob _; Text _], Func _ -> assert false; (* mixed, cannot determine equality *) |
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.
If equality had access to the actor env then we could probably do better here and maybe even get it right (see above)
Co-authored-by: Claudio Russo <[email protected]>
This PR accomplishes following improvements:
actor Self { ... Self ... }
in the actor initialiser (similarly foractor class
)Self.method
from the actor initialiserThe latter should allow setting up timers:
addTimer(b, period, Self.method)
from actor initialiser.NOTES:
Self.method
from actor initialiser is prohibited by the capability checkerSelf.method
from actor initialiser is currently allowed whenmethod
is not defined yet, and results in a descriptor (pair)shared
) of the internal methods with external methods is trapping in the interpreter, but should work in the deployed actor.TODO:
renaming.ml
? — nope, I don't have business in IRactor class
tooSelf
— there is alreadyself-shadow.mo
test/run/issue1464ok.mo
fails — fixed snafuFIXME
sshared
method equality in the interpretersshared
call viability checking (in interpreters)actor
self reference oddity #4731shared func
comparison problem — here: interpreters have trouble comparing shared methods when mixed intern/extern #4732Promise.is_fulfilled
problem