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
How important are circular lists/recursive objects?
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2007-04-03 (12:14)
From: Jon Harrop <jon@f...>
Subject: Re: [Caml-list] How important are circular lists/recursive objects?
On Tuesday 03 April 2007 08:00, Andrej Bauer wrote:
> Brian Hurt wrote:
> > Does anyone  actually use this construct, and if so, for what?
> When I teach my students "theory" of programming languages, we write
> interpreters for mini languages. The recursive data structures are used
> to create closures of recursive functions, environments that contain
> mutually recursive values, closures of objects, etc. Life would be very
> hard without this feature.

There is a nice example here:


Specifically, in the "eval" function:

    | ELetRec(var, arg, body, rest) ->
        let rec vars = (var, VClosure(arg, vars, body)) :: vars in
        eval vars rest

Dr Jon D Harrop, Flying Frog Consultancy Ltd.
OCaml for Scientists