Version française
Home     About     Download     Resources     Contact us    
Browse thread
[Caml-list] Subclasses and pattern matching
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: art yerkes <ayerkes@s...>
Subject: Re: [Caml-list] Subclasses and pattern matching
On Fri, 19 Sep 2003 11:54:31 -0400
katre <katre@henchmonkey.org> wrote:

> art yerkes wrote:
> > You could wrap your items in a union:
> > 
> > exception NoExternalRepForBase
> > 
> > type 'a base_extern_t = 
> >         Derived1 of 'a | Derived2 of 'a
> > 
> > class virtual base =
> > object
> > 	method virtual as_external : unit -> base base_extern_t
> > end
> > 
> 
> Will this allow me to call methods that only exist on the derived
> classes after the pattern match?  I'm not sure this type lets the
> typechecker know exactly which derived class I have.
> 
> katre

I've heard that coca-ml does the rest (though I haven't tried it myself).

http://www.pps.jussieu.fr/~emmanuel/Public/Dev/coca-ml/index-en.html

-- 
"Should array indices start at 0 or 1? My compromise of 0.5 was rejected
 without, I thought, proper consideration."
   - S. Kelly-Bootle

-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners