RE: anonymous record types in variants

From: Manuel Fahndrich (
Date: Mon Feb 15 1999 - 19:03:39 MET

From: Manuel Fahndrich <>
Subject: RE: anonymous record types in variants
Date: Mon, 15 Feb 1999 10:03:39 -0800

I also find this the major annoying feature of CAML records. I frequently
use variant datatypes with a number of fields. Without records, the field
order matters and has to be remembered when creating and accessing such
variants. Anonymous records would be ideal on variants, since they would not
introduce the extra level of indirection that you get when you declare an
explicit record type.


-----Original Message-----
From: Don Syme []
Sent: Monday, February 15, 1999 2:30 AM
To: 'Christopher Jeris';
Subject: RE: anonymous record types in variants

FTR, I've also had a few situations where it seemed most natural to write
similar constructs, but I couldn't.

> The argument of a variant type constructor cannot be an
> anonymous record
> type, i.e.:
> type foo = One of {one: int} | Two of {two: string}
> is rejected at the first {. Of course this is easy to work
> around, just
> give the record types names:
> type foo_one = {one: int}
> type foo_two = {two: string}
> type foo = One of foo_one | Two of foo_two
> But, just out of curiosity, is there a quick explanation of
> why it is this
> way?
> thanks & peace,
> Chris Jeris MIT math grad student and novice OCaml music programmer

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