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-list] Sumtypes of records
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2003-06-02 (21:30)
From: John Max Skaller <skaller@o...>
Subject: Re: [Caml-list] Sumtypes of records
Marcin 'Qrczak' Kowalczyk wrote:

>>type bar_anonymous_record_type_name_123 = { age : int; }
>>type foo = Bar bar_anonymous_record_type_name_123
> Ah, I see. Like in Turbo Pascal (I don't know about Pascal in theory) where it 
> applies to arrays and pointers too. And like structs and unions in C and C++.
> I don't like it because it's confusing. The syntax suggests that record types 
> are built on the fly like tuples (like in SML) but the semantics is that they 
> are explicitly defined somewhere like algebraic types. And this would be the 
> only such case.
> When you would write:
>    type foo = Foo of {x : int}
>    type bar = Bar of {x : int}
> then this is a type error:
>    let f (Foo y) = Bar y
There is no reason for it. The compiler

already does sophisticated signature matching.
There's no reason it can't identify all anonymous
record types with the same structure the
same way it does for tuples (and polymorphic variants).

So this *could* be consistently supported if it

was deemed useful, but I would have to warn
that anonymous types invariable lead to
difficult to understand error messages
(I use polymorphic variants extensively
and regularly get 200 line error messages).

John Max Skaller,
snail:10/1 Toxteth Rd, Glebe, NSW 2037, Australia.

To unsubscribe, mail Archives:
Bug reports: FAQ:
Beginner's list: