acton icon indicating copy to clipboard operation
acton copied to clipboard

Allow calling actor & object methods in `after` statement

Open plajjan opened this issue 2 years ago • 2 comments

after n: x() currently only supports plain functions in the local scope, like we can define a method in the local actor and call that, but if we have an object or another actor we can't call the methods on those. Instead we have to wrap it up in a local function first. Seems a bit verbose? Can we allow after to accept object methods directly?

Like so:

actor Foo():
    def foo():
        print("foo")

actor main(env):
    f = Foo()
    after 1.0: f.foo()

If lambda was accepted that would also make things a little more flexible, but alas, it is not...

plajjan avatar Aug 29 '23 07:08 plajjan

Would be dead simple to support! Just note that once we implement cancelling of after messages, cancellation won't be deterministic in the case a message is directed to some other actor. But I don't see that as a problem per se, it's quite a natural consequence of the asynchronous behavior of actors.

nordlander avatar Aug 29 '23 07:08 nordlander

Yes, agreed. Cancellation of after to other actor would not be deterministic! And that is OK!

plajjan avatar Sep 25 '23 08:09 plajjan