Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

Browse thread
[Q]: Mutable variant types in Caml Light 0.7
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Andrew Conway <arc@l...>
Subject: Re: [Q]: Mutable variant types in Caml Light 0.7

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 =
        | 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,