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 (12:48)
From: ketti <kattlachan@g...>
Subject: Re: [Caml-list] Objects, dynamic cast, Obj.magic abuse and dragons

2008/2/26 Berke Durak <>:
>  Persons, places and objects are things so they inherit from physical.  Hence, a forest is a place that can contain
>  a sword (an object), a dragon (a person) or another place (a small house).  Persons can be contained in places
>  or things (coffins).
>  The problem is that the main game loop gets the current location by taking the container of the hero... which is a
>  physical.  However, it needs to call the place-specific method "go".

I too have only read your code briefly, but i would suggest you use
multiple inheritanse. Coffin would inherit from both object and place.
That way the container of the hero is always a place. In fact, that is
the way i would encode it in java too (using interfaces).