Version française
Home     About     Download     Resources     Contact us    
Browse thread
syntax bug: copying records
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Mackenzie Straight <eizneckam@g...>
Subject: Re: [Caml-list] syntax bug: copying records
On 12/20/05, skaller <skaller@users.sourceforge.net> wrote:
> If x is a record then { x } should be a copy of it. But this
> doesn't work, I am using this ugly workaround instead:
>
> { x with dummy_field = x.dummy_field }
>
> Surely there is a better way?

Perhaps:

let copy (x:'a) = (Obj.obj (Obj.dup (Obj.repr x)) : 'a)