Non-destructive record update??

From: Donald Syme (
Date: Wed Apr 15 1998 - 01:27:20 MET DST

Subject: Non-destructive record update??
Date: Wed, 15 Apr 1998 00:27:20 +0100
From: Donald Syme <>
Message-Id: <>

[Sorry - wrong subject on previous message]

I think O'Caml is absolutely excellent in general, but
why doesn't it have some form of non-destructive record
field update, as in

type x = {y : int};;
let x = {y=1};;
(x.y <- 2).y = 2;; (* true *)
x.y = 1;; (* true *)

???? (well, at least I haven't found it if it does...)

If I have N fields in my records, and if I need non-destructive update
because I'm actually writing things functionally (rather common in
a functional language), then I end up writing N*N lines worth of
non-destructive update functions myself - yeach!

Thanks in advance,
Don Syme

At the lab:                                          At home:
The Computer Laboratory                              Trinity Hall
New Museums Site                                     CB2 1TJ
University of Cambridge                              Cambridge, UK
CB2 3QG, Cambridge, UK
Ph: +44 (0) 1223 334688                    

This archive was generated by hypermail 2b29 : Sun Jan 02 2000 - 11:58:14 MET