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
A function returning itself
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2008-11-24 (22:43)
From: Mathias Kende <mathias@k...>
Subject: Re: [Caml-list] A function returning itself
Le lundi 24 novembre 2008 à 23:37 +0100, Paolo Donadeo a écrit :
> Since I don't completely understand the inner implications of
> -rectypes and a quick check in the mailing list archives revealed that
> "rectypes is evil", the question I pose is whether is it possible to
> avoid the -rectypes option in this particular case, possibly with the
> definition of an auxiliary type.

Usually, using an intermediate type with a constructor, you can achieve
such thing. Here, something along the line of this should work :

type r = {res: int; f: int -> int -> r}
let rec fct a b = {res = a + b; f = fct}