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
The option -rectypes
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 1999-11-24 (08:18)
From: Gerd Stolpmann <Gerd.Stolpmann@d...>
Subject: The option -rectypes
I have some code that compiled in 2.02, but in 2.03 I need the new option
-rectypes of the compilers.

My class definitions look like (the signatures)

class type [ 'node ] extension =
  object ('self)
    method clone : 'self 
    method node : 'node
    method set_node : 'node -> unit

class type [ 'ext ] node =
  object ('self)
    constraint 'ext = 'ext node #extension
    method extension : 'ext
    (* ... more methods ... *)

This works in both versions out of the box. If I add 

val f : 'a node extension as 'a

the 2.03 compiler only accepts the type if I add -rectypes. I have several

- What is the effect of -rectypes? (I did not find a good explanation in the
- What is the background of this change?
- I have thought about the type 'a node extension as 'a. If I apply the
  constraint of "node", the condition must hold that 
      ('a node extension as 'a) node extension 
  unifies with
      ('a node extension as 'a) node #extension
  Normally, a closed class type does not unify with an open class type,
  and I wonder why this is accepted at all.

  Without -rectypes, the 2.03 compiler only accepts
      val f : 'a node #extension as 'a
  but this is a much more difficult type.

Gerd Stolpmann      Telefon: +49 6151 997705 (privat)
Viktoriastr. 100             
64293 Darmstadt     EMail:   Gerd.Stolpmann@darmstadt.netsurf.de (privat)