Re: [Q]: Mutable variant types in Caml Light 0.7

Andrew Conway (arc@labri.u-bordeaux.fr)
Thu, 19 Oct 1995 16:16:10 +0100

Message-Id: <9510191516.AA04207@waves>
From: Andrew Conway <arc@labri.u-bordeaux.fr>
To: caml-list@margaux.inria.fr
Subject: Re: [Q]: Mutable variant types in Caml Light 0.7
In-Reply-To: Your message of "Thu, 19 Oct 1995 11:31:13 +0100."
<9510191031.AA19481@gr6>
Date: Thu, 19 Oct 1995 16:16:10 +0100

Christian Boos wrote:
> ...
>Si ce raisonnement est correct, une amélioration pourrait alors être
>effectuée, permettant de cumuler efficacité et souplesse :
> - soit une grosse refonte de la syntaxe des types, pour avoir des
>déclarations à la SML (mais plus expressives, en raison du 'mutable') :
>
> type t = A of { a:int; mutable b:float; c:string; }
>
> - soit en faisant une modification sur la syntaxe de l'extension 3.6
>permettant d'avoir des types "union" mutables :
>
> type t = A of int * (mutable float) * string

Moi aussi!

Why I would like it? Well, although I generally like strictness,
sometimes lazy lists are useful. So I decided to make some lazy list
routines. I used the following type:

type 't lazylist =
EndLL
| Element of 't llcont
| Unconstructed of (unit -> 't lazylist)
and 't llcont = { value : 't ; mutable next : 't lazylist}
;;

The trouble is that takes 5 words per evaluated element, whereas
with Christian's suggestion it could be done in 3 words like
normal lists, as well as avoiding the ugliness in the above type
definition. Neither are huge things for me, but since it has already been
suggested, I second it.

( Incidentally, is there a nicer basic structure for lazy lists? )

Thanks again,

Andrew.