-
Notifications
You must be signed in to change notification settings - Fork 2
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
interop mapping for classes that act like interfaces #8
Comments
Especially considering the disjointness problem, it seems to me like the class types shouldn’t be visible at all. Is it possible to make // Interface Class
DartClass c1 = DartClass();
// Interface Class
DartClass() c2 = DartClass;
// Interface
DartClass c3 = c2(); Another question: do |
Without typechecker support, it would be possible to map Dart constructors to static factory methods. But we'd still be without the ability to extend Dart classes, which may be too limiting/inconvenient. Beyond that, I'm not sure.
Good point. There is no way to prevent things like a Dart class |
What precisely does this mean? Does Dart support multiple inheritance for classes? Or, when I "satisfy" a class, do I have to reimplement all its operations? I don't understand the semantics here. |
There are no
This issue is primarily focussed on 1 & 2, since I'm not sure 3 adds any additional complexity to subtyping. |
@jvasileff OK, then could we model this as:
Wouldn't that capture the semantics, without requiring strange generated names? |
Yes, I think it's a good idea to map constructors to static functions, but we still need a class to support extending Dart classes in Ceylon. We also need a name for the functions for default (nameless) Dart constructors. |
The current implementation status is that we have:
Gotchas are:
10/16/2016 edit: classes like |
I like the static inner class. Makes sense to me. Sent from my iPhone
|
In Dart, all classes can be used as interfaces. The Ceylon translation would be:
which of course is not legal in Ceylon.
There seems to be no option but to have each Dart class map to two separate types: a Ceylon interface and a Ceylon class that satisfies that interface.
Either the class or interface will need a synthetic name.
Scenario 1: Use
class DartClass
andinterface I_DartClass
DartClass
toI_DartClass
DartClass
for parameter types in Ceylon code would be discouraged;I_DartClass
should be used instead, for maximum flexibility.DartClass
would be use for instantiations and extensions in Ceylon code (e.g.DartClass()
and... extends DartClass()
.I_DartClass
would be erased toDartClass
by the backend compiler.Scenario 2: Use
class C_DartClass
andinterface DartClass
DartClass
.C_DartClass
for anything other than instantiations and extensions would be discouraged.C_DartClass
would be erased toDartClass
by the backend compiler.Perhaps Scenario 2 is the most natural, since the synthetic name would be used less frequently, and when needed (for instantiation & extension), its use would be forced by the typechecker.
A further concern is that classes
DartClass_A
andDartClass_B
that do not share a subtyping relationship are not guaranteed to be disjoint, which breaks Ceylon's type system. Adopting scenario 2 (which helps reduce unintentional use of the identifier that maps to theclass
) should help to avoid this unsoundness.The text was updated successfully, but these errors were encountered: