[plt-scheme] union types in Swindle?
On Jun 2, Doug Orleans wrote:
> [This is pretty much just for Eli, but I thought I'd ask in public in
> case anyone else has some thoughts.]
>
> Have you thought about union types in Swindle?
Yes.
> I'm finding myself often wanting to define methods that specialize
> on things like "(or <foo> (singleton #f))" or "(or <pair> <null>)"
> or "(or <string> <symbol>)". I think I could do this by making
> custom generic and method metaclasses and override compute-methods
> and compute-method-more-specific?,
A saner way to do this would be to have a way to create a union class.
I played with the idea for a while, and I think that my conclusion was
that it was not worth it to add it to the object system.
> but it seems like it would be easy to add this to "subclass?",
> "instance-of?", "specializer?", and "more-specific?" (which are all
> plain procedures instead of generics).
I wouldn't like adding specializers that are not classes... Making a
union class is a much better solution. But then come questions like
what should the class-cpl be, and is there anything that
(union <string> <symbol>) is more specific than, etc.
--
((lambda (x) (x x)) (lambda (x) (x x))) Eli Barzilay:
http://www.barzilay.org/ Maze is Life!