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
Caml sur Rhapsody
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 1998-04-15 (09:14)
From: Donald Syme <Donald.Syme@c...>
Subject: Non-destructive record update??

[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