Browse thread
[Caml-list] default values for record field definitions
[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
| Date: | -- (:) |
| From: | FabienFleutot <fleutotf@e...> |
| Subject: | Re: [Caml-list] default values for record field definitions |
> > Why not to introduce a syntax for default values of record fields:
> > type rec1 = { attr1: type1 = val1; attr2: type2; attr3: type3 = val3 }
>
> 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 }
That seems to be the most usual workaround, but it'd be nice to allow
writing:
let x = {default_rec1 with (* Nothing! *) }
to produce a copy of default_rec1 instead of a pointer to it, as would do:
let x = default_rec1
(useful when there are some mutable fields). It doesn't seem to be difficult
to add to the compiler...
-------------------
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