From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id PAA01845; Sat, 21 Jul 2001 15:16:07 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id PAA01862 for ; Sat, 21 Jul 2001 15:16:07 +0200 (MET DST) Received: from verdot.inria.fr (verdot.inria.fr [128.93.11.7]) by concorde.inria.fr (8.11.1/8.10.0) with ESMTP id f6LDG6H16758 for ; Sat, 21 Jul 2001 15:16:06 +0200 (MET DST) Received: (from ddr@localhost) by verdot.inria.fr (8.9.3/8.9.3) id PAA19580 for caml-list@inria.fr; Sat, 21 Jul 2001 15:16:06 +0200 Date: Sat, 21 Jul 2001 15:16:06 +0200 From: Daniel de Rauglaudre To: caml Subject: Re: [Caml-list] default values for record field definitions Message-ID: <20010721151606.X12644@verdot.inria.fr> References: <3B565E7B.35BB6073@quasar.ipa.nw.ru> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Mailer: Mutt 1.0us In-Reply-To: <3B565E7B.35BB6073@quasar.ipa.nw.ru>; from avv@quasar.ipa.nw.ru on Wed, Jul 18, 2001 at 09:13:47PM -0700 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk Hi, On Wed, Jul 18, 2001 at 09:13:47PM -0700, Alexander V. Voinov wrote: > Why not to introduce a syntax for default values of record fields: > type rec1 = { attr1: type1 = val1; attr2: type2; attr3: type3 = val3 } > > It this case constructions of the form > let x = { attr2 = val2 } are possible, with other fields filled by val1, > val3. > > Can it be done via camlp4? No, it is not purely syntactic. The definition type has to generate a "normal" type definition *plus* some appropriate function to set the default values to the undefined fields. This is possible to do that in Camlp4, but I don't see what interface give to this function. And for the record usage, it should call this function, but I am not sure it is possible. And we have to change that for all defined record expressions. Simpler if there is a specific syntax for those records. And I am not sure it would be enough. An argument to say that it is not syntactic is the fact that the record fields have a meaning, what is typically a work at typing time. The fact that "attr2" is a record field (with a default value or not) is typing. In Camlp4, at parse time, there is no link between the "attr2" of the record definition and the "attr2" of the record expression. They can even exist in different compilation units: in this case, syntactic analysis can do nothing. -- Daniel de RAUGLAUDRE daniel.de_rauglaudre@inria.fr http://cristal.inria.fr/~ddr/ ------------------- Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr