From: Ian Zimmerman <itz@speakeasy.org>
To: caml-list@inria.fr (OCAML)
Subject: Re: [Caml-list] p4 (newbie) question
Date: 22 Jan 2002 06:46:32 -0800 [thread overview]
Message-ID: <863d0yzbnb.fsf@speakeasy.org> (raw)
In-Reply-To: <20020122094714.B1462@verdot.inria.fr>
itz> shouldn't there be 2 distinct nodes like this
itz>
itz> <:expr< $e1$ . $e2$ >> : access in records
itz> <:expr< $me1$ . $e2$ >> : access in modules
Daniel> No: in these two quotations, e1, e2, me1, e2 are not some kind
Daniel> of "keywords" like you seem to believe, but variables. These
Daniel> quotations are (resp.) equivalent to:
Daniel> MLast.ExAcc (loc, e1, e2)
Daniel> MLast.ExAcc (loc, me1, e2)
Daniel> which cannot discriminate according to the cases
Daniel> record/modules as you see.
Well, I guess I can rephrase my question then: shouldn't there be both
MLast.ExRecAcc (loc, e1, e2) and
MLast.ExModAcc (loc, me1, e2)
?
After all, doesn't p4 have to pass distinct trees to the compiler
proper in these two cases?
Daniel> The difference is done by the first parameter when it
Daniel> represents (or not) an uppercase identifier:
Daniel> MLast.ExAcc (loc, MLast.ExUid loc s, e2)
Daniel> which can be written with quotations as:
Daniel> <:expr< $uid:s$ . $e2$ >>
Daniel> That is (above) the code of contructing a module access if s
Daniel> is a string holding the module name and e2 is an
Daniel> expression. If you already know the name of your module, and
Daniel> if it is e.g. Foo, you can write it:
Daniel> <:expr< Foo . $e2$ >>
But I don't know the name like that, it is not fixed; I am trying to
parse that as well. So my me1 can be any module access path in
general (OK, no functor applications for now, but arbitrary depth).
It would be a different story if the dot were right-associative; then,
indeed, I could write something like
let barexp = <:expr< Bar . $exp$ >> in
<:expr< Foo . $barexp$ >>
But this is ungrammatical; normal ocaml grammar says that
Foo.Bar.exp
is to be parsed as
(Foo.Bar).exp
Antoher question, and one I am afraid I know the answer to:
where/what is the quotation for applicative record update
{foo with bar = expr} ?
--
Ian Zimmerman, Oakland, California, U.S.A.
GPG: 433BA087 9C0F 194F 203A 63F7 B1B8 6E5A 8CA3 27DB 433B A087
In his own soul a man bears the source
from which he draws all his sorrows and his joys.
Sophocles.
-------------------
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
next prev parent reply other threads:[~2002-01-22 14:46 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-01-21 18:22 Ian Zimmerman
2002-01-22 8:47 ` Daniel de Rauglaudre
2002-01-22 14:46 ` Ian Zimmerman [this message]
2002-01-22 15:05 ` Daniel de Rauglaudre
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=863d0yzbnb.fsf@speakeasy.org \
--to=itz@speakeasy.org \
--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