English version
Accueil     À propos     Téléchargement     Ressources     Contactez-nous    
Browse thread
[Caml-list] about Obj.magic
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Warp <warplayer@f...>
Subject: Re: [Caml-list] about Obj.magic
> > One case can be 'almost-legal' : downcasting an object to its
implementation
> > class if you're sure that it has been previously upcasted to the
interface
> > type class.
> >
> And here is how to break your code:
>
> class c = object method a : unit end
> let i = new_intf (new c)
>

True.
In fact that sample can't be used if the class also use shadow types which
prevents the user from writing his own class and then making the program
crash.

Nicolas Cannasse

-------------------
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