caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Daniel de Rauglaudre <daniel.de_rauglaudre@inria.fr>
To: caml <caml-list@inria.fr>
Subject: Re: [Caml-list] default values for record field definitions
Date: Sat, 21 Jul 2001 15:16:06 +0200	[thread overview]
Message-ID: <20010721151606.X12644@verdot.inria.fr> (raw)
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

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


      parent reply	other threads:[~2001-07-21 13:16 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-07-19  4:13 Alexander V. Voinov
2001-07-19  6:43 ` Ian Zimmerman
2001-07-19 13:35   ` David Mentre
2001-07-19  7:02 ` Dmitry Bely
2001-07-19 16:20   ` Alexander V. Voinov
2001-07-20  9:42   ` FabienFleutot
2001-07-21 13:16 ` Daniel de Rauglaudre [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20010721151606.X12644@verdot.inria.fr \
    --to=daniel.de_rauglaudre@inria.fr \
    --cc=caml-list@inria.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).