-
Notifications
You must be signed in to change notification settings - Fork 107
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
Conversation
9c6ab4d
to
e2e0255
Compare
d8b1c69
to
8933498
Compare
this is also how `ClassD` is done
resolves a FIXME
resolves a FIXME
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.
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.
On first look this might work, the callback could simply define the method as interpret_obj
is iterating over the decs.
| 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)
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.
Yes, but I wouldn't hold my breath.
Co-authored-by: Claudio Russo <[email protected]>
* fix for ir_interpreter * typos * refactor * Update src/ir_interpreter/interpret_ir.ml * Update src/lowering/desugar.ml * update output * revert changes since real bug was elsewhere in lowering * update test output * delete unused declared_defined_id * missing test file
* fix for ir_interpreter * typos * refactor * Update src/ir_interpreter/interpret_ir.ml * Update src/lowering/desugar.ml * update output * revert changes since real bug was elsewhere in lowering * update test output * deal with self * refactor * delete unused declared_defined_id * delete unused declared_defined_id * missing test file --------- Co-authored-by: Gabor Greif <[email protected]>
caller(Self.method); | ||
caller(method); | ||
debugPrint (debug_show(principalOfActor Self)); | ||
debugPrint "So far so good!"; |
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.
Strange, this one doesn't generate a a type error about trailing
debugPrint, but pass-class-self does?
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.
Yeah, very bizarre.
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.
LGTM. Can you open an issue to improve function equality in the interpreters in future?
Users should appreciate this... |
Yeah, already did: #4732. |
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.Also fixes the hole in definedness analysis (#4731).
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.There is an idea inside to fix these problems.
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 — experiment: simpler version of claudio/self-pass #4735