Version française
Home     About     Download     Resources     Contact us    
Browse thread
Shallow copy of a record
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Chris King <colanderman@g...>
Subject: Re: [Caml-list] Shallow copy of a record
On Sat, 22 Jan 2005 15:49:09 +0900 (JST), Jacques Garrigue
<garrigue@math.nagoya-u.ac.jp> wrote:

> This does not exist, and with good reason: there is no way in the type
> system to define a function which works on all records, but only
> records. So to do the copy you need to know at least one of the labels
> of the record, which in turn gives you its type.

Isn't it the foo in {foo with a=b} that determines the type, though?

> Another approach, which is potentially unsafe, is to use the Obj.dup
> function.

That seems like it would do the trick for now - thanks!