Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

Browse thread
Objects, dynamic cast, Obj.magic abuse and dragons
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2008-02-26 (16:25)
From: Berke Durak <berke.durak@e...>
Subject: Re: [Caml-list] Objects, dynamic cast, Obj.magic abuse and dragons
Dirk Thierbach wrote :
> I think I wouldn't use objects at all in this situation. You're trying
> to model the location-tree of "physical" things. A tree must be uniform
> in its contents, but you want to put different things into it. That
> means you must use an algebraic type, or variants. I'd probably either
> use a zipper, or connect the tree nodes with "refs" for the non-pure
> version. 

You are preaching to the choir.  I'm not Gerd Stolpmann and I don't use
objects very much because every time I try I get seven-page-long errors.

However it seems that objects could be actually useful in situations
where you have a hierarchy of objects with behaviours, such as a graphical
user interface made of widgets, or, say, a text adventure.