caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Wolfgang Lux <lux@pan.uni-muenster.de>
To: Emmanuel Engel <Emmanuel.Engel@lri.fr>
Cc: caml-list@inria.fr
Subject: Re: Classe recursive et heritage
Date: Tue, 23 Jun 1998 12:01:49 +0100	[thread overview]
Message-ID: <199806231101.MAA12573@pan.uni-muenster.de> (raw)
In-Reply-To: (Your message of Sun, 21 Jun 1998 16:05:37 +0200.) <358D1330.89DB13F9@lri.fr>

[Sorry, for the answer not being in french, but I'm still better in 
reading french than in writing :-(]
> [...] 
> Mais cela ne correspond  pas a mon  besoin puisque les fils gauches et
> droit de cette nouvelle classe ne sont que des  arbres non decores. En
> fait il  me semble que, ce  dont  j'ai besoin c'est,  dans la premiere
> definition, d'une variable de type (type au sens typage) "self" qui me
> permettrai alors de  dire que les fils  gauche  et droit sont  du meme
> type  que  la classe (soit  le point  fixe de  cette definition). Cela
> donnerai alors
> 
> class ('a) tree as 'self (g:'self) (d:'self) =
>   val fg = g
>   val fd = d
> end;;
> 
> class ('a) labelled_tree g d (i:int) =
>   inherit ('a)tree g d
>   val un_entier = i
> end;;
> 
> Dans ce  cadre la, le  inherit aurait pour   consequence de modifer le
> point  fixe  de   la definition    pour  creer  la    nouvelle  classe
> labelled_tree.  Mon probleme est que je n'ai  pas trouve comment faire
> en  O'caml.  Est-ce possible? Si  non ou est  le probleme  ? Le typage

You can simply define this in OCaml as follows (Note that I've also 
added accessor methods to the classes):

class 'a tree (g : 'b) (d : 'b) : 'b =
  val fg = g
  val fd = d
  method fg = fg
  method fd = fd
end;;

class 'a labeled_tree g d (i : int) =
  inherit ('a) tree g d
  val un_entier = i
  method label = un_entier
end;;

Regards
Wolfgang Lux
--
Wolfgang Lux				  Phone: +49-251-83-38263
Institut fuer Wirtschaftinformatik	    FAX: +49-251-83-38259
Universitaet Muenster		Email: lux@helios.uni-muenster.de






      parent reply	other threads:[~1998-06-23 15:44 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1998-06-21 14:05 Emmanuel Engel
1998-06-23  9:17 ` Sylvain BOULM'E
1998-06-23 11:01 ` Wolfgang Lux [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=199806231101.MAA12573@pan.uni-muenster.de \
    --to=lux@pan.uni-muenster.de \
    --cc=Emmanuel.Engel@lri.fr \
    --cc=caml-list@inria.fr \
    --cc=lux@helios.uni-muenster.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).