<fourslice>
Oh, yeah, that's what I mean, can you add more... I don't know the word... can you add more "types" to variants as you go?
<graydon>
I think the term you want is "type constructors", and yes.
<fourslice>
Hmm... where can I find info on that?
<graydon>
though only add -- not remove. you can refine a variant type with more variants.
<graydon>
did you see the page I pointed to? scroll down to the section on variants.
<fourslice>
Yeah, I think that'd be a good way to do class introspection
<graydon>
perhaps. you can also just use subclassing though.
<graydon>
and visitor methods
<graydon>
class introspection"
<fourslice>
I don't know if subclassing will help too much, my problem is that when two things collide they are sent as superclasses so I need a way to figure out what hit what
<graydon>
hm. I don't see why you need to break encapsulation for that.
<fourslice>
Well, hitting different things has different effects, so depending on the thing hit, different stuff has to happen... what would you recommend?
<graydon>
either virtualize the behavior (make it a member of the objects affected), or have the object return an object representing their preferred affect, or if you want to disambiguate from outside the objects you can visit them and have them call you back informing you of their type
<graydon>
i.e. typical C++ solutions.
<fourslice>
Hmm... but if I can add on to variants, I can typecase it and find out what it is in one fell swoop
<fourslice>
i can just add on to some variant called "classtype" Foo of foo
<graydon>
if you like. I don't see how adding on to them makes them any more useful than a normal sum type, though.
<fourslice>
It doesn't, it just makes them easier to read
<fourslice>
Since I can add on to it around where the class is
<graydon>
I think you're thinking of different things, when you say "add on to it"
<graydon>
you define a new type, when you refine a variant.
<graydon>
a refined type, which the old one is a subset of, and can be used in place of.
<fourslice>
What would be the problem with that?
<graydon>
you can't say "type x += Some_New_Constructor"
<graydon>
you have to say "type x = 'Some_new_constructor | y"
<graydon>
so you're going to keep defining new types. up to you.
<graydon>
anyway, I gotta go. wife wants me at home :)
<fourslice>
Oh.... thanks for all your help!
<graydon>
np. enjoy. look into the normal C++ disambiguation techniques.
graydon has left #ocaml []
fourslice has quit ["Client Exiting"]
pHa has quit [carter.openprojects.net irc.openprojects.net]