Repository navigation
Replies: 1 comment 1 reply
|
As one of the original/main designers on Slang, I'm happy to see some healthy criticism of our current approach to existential types, since it is one of the messier bits of the design that has also led to many complications in the compiler implementation. For the short version of things: I agree that it would be good for Slang to have a dedicated construct for opening a value of existential types within a scope/closure. We discussed such a construct during the original design process, but couldn't land upon a syntax we were happy with. For the longer version... The handling of existential types in the Slang language design (and the compiler implementation) has a lot of problems. I've been wanting to pursue several systematic cleanups of the design/implementation for quite some time, but it has been hard to justify using my time that way when most Slang users don't use existentials at all. While the proposed feature would be nice to have, I would rather see it show up as part of a coherent overhaul of the approach to existential types in Slang, with a goal of putting the current language constructs on more firm theoretical footing. To be clear, I don't see us removing many of the capabilities that existentials in Slang currently afford (except possibly as part of incremental steps toward a more solid implementation). The ability to use a value of interface-constrained existential type as a kind of dynamically-dispatched "object" is probably here to stay, just because that is the exact capability that users had requested years ago that pushed us to add existential types at all. One of the biggest cleanups I'd like to push through is making the Slang language/compiler properly distinguish between an interface like The only caveat I'd give about a feature proposal like this is that we may need to make sure the foundations are solid before building more on top of them. I appreciate the perspectives of those with more PLT experience, and I think they can help us continue to improve the Slang language, but I don't want us to end up with a language/compiler that has a veneer of rigor on top of a rotten core. |
Uh oh!
There was an error while loading. Please reload this page.
I am not satisfied with the current syntax design for existential types. Slang should provide a very simple way to implement them.
We should not allow existential values to invoke virtual methods directly. Even if we do, it should only be treated as syntactic sugar. This syntax is too limited in expressive power and cannot solve problems such as self-comparison.
Instead, Slang should provide an accept syntax, where one existential value accepts one generic function at a time. One existential value and one function makes it complete type safety. In fact, this is precisely the Church encoding of existential types.
The implementation should also be straightforward. From my quick reading of the relevant materials, Slang already supports polymorphic of generics already. At the implementation level, it should be sufficient to pass the existential value directly to the polymorphic generic function.
All reactions