Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

Browse thread
[Caml-list] p4 (newbie) question
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Ian Zimmerman <itz@s...>
Subject: Re: [Caml-list] p4 (newbie) question

itz> shouldn't there be 2 distinct nodes like this
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


is to be parsed as


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.
Bug reports:  FAQ:
To unsubscribe, mail  Archives: