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

>let foo x = x.bar
>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.

Chris

-------------------
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