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 (06:33)
From: Chris Hecker <checker@d...>
Subject: Re: [Caml-list] Sumtypes of records

>let foo x =
>What is the type of foo if there is no named record in scope having field bar?

It could have a type, it just doesn't have a programmer defined name.  This 
has nothing to do with having the same field names in various 
records...field names would hide previous ones just like they [annoyingly] 
currently do.  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

The only difference is you wouldn't be able to use "bar_anon...123" 
explicitly, only via inference since it's generated.  This isn't a big deal 
or a high priority to add, but I don't see why it wouldn't just work and be 
somewhat useful.


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