-
Notifications
You must be signed in to change notification settings - Fork 34
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
dynamic interfaces as structural types #1400
Comments
Why would Also, couldn't then, dynamic interfaces satisfy non-dynamic interfaces? shared dynamic Foo
satisfies {Anything*}
{
shared actual String first;
} Then, two completely unrelated types would be subtypes of |
Well, yeah. And they would be very inefficient.
No, I don't think we should allow that because there are some things that you can do with / assume about ordinary interfaces that you can't do with / assume about |
The first challenge (though maybe surmountable) is making this work for |
@RossTate ah, good point. Hrm. I asume languages like Go handle that right? |
I admit, I don't know what Go does. If they do, the challenge I pointed out is much easier for them, since they're type system is much smaller. |
Currently the only way you can assign a value to a
dynamic
interface type is by assigning an expression with no type within adynamic
block on JavaScript.It was suggested here that we let you assign a typed expression, performing a structural type check. For example:
I don't see a very good reason to not allow this. The work for structural checking of schemas basically parallels the stuff @quintesse already had to do for
native
, so it's a problem we've already bitten off.A change we would have to make would be to disallow runtime type checks like
is Named
, which currently merely evaluate tofalse
. They should be disallowed at compile time.To be clear: this would amount to Go-style structural typing.
The text was updated successfully, but these errors were encountered: