Version française
Home     About     Download     Resources     Contact us    
Browse thread
[newbie] Define and use records in sum types
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Markus Mottl <mottl@m...>
Subject: Re: [newbie] Define and use records in sum types
On Tue, 11 Jul 2000, David Mentré wrote:
> I would like to define a sum type with records as constructor
> parameters, records with the same field names. 

It is unfortunately not possible to use records with the same names at the
same time without putting them into separate modules.

> It *seems* to work but, in fact, the a_rec definition is masked by b_rec
> definition:

Exactly: names of record fields get overridden by subsequent definitions.
There is no way to get the "old" meaning back without the use of modules.

> The rationale behind this question: I find records more clear that
> tuples in source code.

Using records makes sources more readable and also easier to maintain. For
example, the "with" statement as in

  { some_record with some_field = some_value; ... }
  
allows adding fields to records without breaking code.

Best regards,
Markus Mottl

-- 
Markus Mottl, mottl@miss.wu-wien.ac.at, http://miss.wu-wien.ac.at/~mottl