Version française
Home     About     Download     Resources     Contact us    
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: -- (:)
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
   \__/       qrczak@knm.org.pl
    ^^     http://qrnik.knm.org.pl/~qrczak/

-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners