-
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
Allow composite traits to be used as types #314
Allow composite traits to be used as types #314
Conversation
I think for With this commit, single trait type
Should this compile? |
Your example program should definitely compile! I will fix that, and will see if I can clean up code using |
Fixed bug found by @albertnetymk as well as several others (and added a test case). Ready for review again! |
Why introduce another variable inside trace function in
Why is The change of signature of Judging from the fact that |
The new function
Nice catch! Fixing that now.
For the current usage, I agree that one level of checking would be enough (note that this is not part of this PR though). The question is if
Subjective, but also right! Separated into
Maybe, but then we would need to introduce an additional category for what is currently considered to be a |
@EliasC Could you resolve the conflict? |
There was no support in the backend for using composite traits as types, causing programs like the following to crash. ``` trait T trait U passive class C : T + U -- This is fine, not used as a type class Main def main() : void new C : T + U -- This crashes the compiler ``` This commit adds proper backend support for types like `T + U`, introducing the C type `capability`, which is a pointer to a struct that contains only the self type that prefixes all passive classes. This means that any reference to a passive class (trait and capability references included) can be cast to a `capability` and used as such. This commit also adds proper tracing support for trait types, which were erroneously ignored previously during tracing. It should therefore now be safe to have fields of trait type or to pass trait references between active objects.
@albertnetymk: Rebased and resolved! |
I don't think I got your point on
The trace function changes from:
to:
Seems to me unnecessary.
Well, it kind of depends on how one view it.
It doesn't make much to ask |
Regarding
generates the following trace-function
which avoids the the double memory access needed by the following line:
Sounds dangerous to me. The current fix only changes the behavior for capabilityTypes (which is what the commit promises) whereas your change affects the behavior for many types.
The fact that |
OK, I see. I disagree on comments on Would merge this in one hour, if no objections. |
Allow composite traits to be used as types
There was no support in the backend for using composite traits as types,
causing programs like the following to crash.
This commit adds proper backend support for types like
T + U
,introducing the C type
capability
, which is a pointer to a struct thatcontains only the self type that prefixes all passive classes. This
means that any reference to a passive class (trait and capability
references included) can be cast to a
capability
and used as such.This commit also adds proper tracing support for trait types, which were
erroneously ignored previously during tracing. It should therefore now
be safe to have fields of trait type or to pass trait references between
active objects.