-
Notifications
You must be signed in to change notification settings - Fork 26
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
Compilation of asynchronous self-calls through let is broken #41
Comments
In hindsight, this seems to be a duplicate of #18. |
Related however is the discussion in #40 on whether or not we should try to disallow asynchronous calls on (aliases of) |
I disagree. On the implementation level it seems to be very related. The common problem (which is not the full story in either case) seems to be that there are two types of |
Related, yes. Duplicate, no. |
+1 |
Fixed as of 9f917d2. The following code now works. This should allow @supercooldave to implement streams the way he wanted in the first place. This code works: class Foo
def fr0b() : bool
true
def foo() : Fut bool
let that = this in{
that.fr0b();
}
def bar() : Fut bool
let that = null : Foo in{
that = this;
that.fr0b()
}
def baz() : Fut bool
let id = \ (x : a) -> x
that = id(this)
in
that.fr0b()
class Main
def main() : void
let x = new Foo in{
assertTrue(get get x.foo());
assertTrue(get get x.bar());
assertTrue(get get x.baz());
print "Done!"; |
Summary: when compiling
let this = that in that.foo()
, the type ofthis
(in the C-level) should be changed from the "internal type" to the "external type" (aka.pony_actor_t*
).The long of it
The following Encore code uses the "standard let-binding trick" to achieve an asynchronous call on
this
(last line, including all code for completeness):However, the method gets compiled thus (se my
XXX
marking below to spot the error):The problem here is that
this
has two different types (at the C level). When we interact withthis
as an actor, we use thepony_actor_t
type, but normally we want theStreamFiller_data
type that allows field access and synchronous method calls.The text was updated successfully, but these errors were encountered: