English version
Accueil     À propos     Téléchargement     Ressources     Contactez-nous    

Ce site est rarement mis à jour. Pour les informations les plus récentes, rendez-vous sur le nouveau site OCaml à l'adresse ocaml.org.

Browse thread
state pattern...
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2005-06-28 (12:24)
From: Michael Wohlwend <micha-1@f...>
Subject: Re: [Caml-list] state pattern...
thanks for your reply, it's increasing my understanding of the object system, 
although there are some (or more... :-) open points:

class ['state] context s =
 object (this:'self)

what are the reasons to give 'this' a type, and isn't 'self a type-variable? I 
thought it ('this') has the type of the class (= _context) ? I don't 
understand why and when it is needed to give the object a type.
The same with:
class state1 = object (this : _ #state) ...  end

I thought class state1 is a subtype (or implementing the class-type) #state, 
since the methods are the same. Why does it help to give the obejct a type?

thanks for your help, I would really like to understand the object system 
better. The state machine is surely better written using records and 
function; but this (supposed to be) little task is/was helping me indeed 
learning more of the class system. (And I hate it, not being able to solve a 
problem, which seems to be an easy one :-)