Version française
Home     About     Download     Resources     Contact us    
Browse thread
[Caml-list] default values for record field definitions
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Dmitry Bely <dbely@m...>
Subject: Re: [Caml-list] default values for record field definitions
"Alexander V. Voinov" <avv@quasar.ipa.nw.ru> writes:

> It may well be that I'm not in the first hundred of those who proposed
> this, if so - sorry :-).
> 
> Why not to introduce a syntax for default values of record fields:
> 
> type rec1 = { attr1: type1 = val1; attr2: type2; attr3: type3 = val3 }
> 
> It this case constructions of the form
> 
> let x = { attr2 = val2 } are possible, with other fields filled by val1,
> val3.
> 
> Can it be done via camlp4?

Why don't you like

type rec1 = { attr1: type1; attr2: type2; attr3: type }
let default_rec1 = { attr1 = init_val1; attr2 = init_val2; attr = init_val3 }
...
let x = { default_rec1 with attr2 = val2 }

?

Hope to hear from you soon,
Dmitry


-------------------
Bug reports: http://caml.inria.fr/bin/caml-bugs  FAQ: http://caml.inria.fr/FAQ/
To unsubscribe, mail caml-list-request@inria.fr  Archives: http://caml.inria.fr