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-05-18 (07:46)
From: Marcin 'Qrczak' Kowalczyk <qrczak@k...>
Subject: Re: [Caml-list] Sumtypes of records
Dnia nie 18. maja 2003 08:33, Chris Hecker napisa³:

> This is just about whether there's some way to do anonymous
> records.  So for "Bar { age : int; }" the compiler would generate some
> internal name to use for the record type.  It would be shorthand for:
> 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

   __("<         Marcin Kowalczyk

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