caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* 2 camlp4 questions
@ 2007-04-05 21:22 Hendrik Tews
  2007-04-05 21:54 ` [Caml-list] " Martin Jambon
  2007-04-06  0:52 ` Nicolas Pouillard
  0 siblings, 2 replies; 3+ messages in thread
From: Hendrik Tews @ 2007-04-05 21:22 UTC (permalink / raw)
  To: caml-list

Hi,

I am still reading the camlp4 sources:

1. Is there a special @loc quotation form? For instance in
   camlp4/Camlp4Bin.ml line 141

  [ <:sig_item@loc< # $n$ $str:s$ >> -> Some (loc, n, s)

   What does it do? Or is ``sig_item@loc'' just the identifier of
   the quotation expander?

2. Camlp4Bin calls a cleaning pass before printing. The cleaner
   does things like 

      <:expr< $e$; $ <:expr<>> $ >> -> self#expr e

   What do these empty quotations ``<:expr<>>'' stand for? Are
   these just the things that filters leave behind if they delete
   a node?


Bye,

Hendrik


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [Caml-list] 2 camlp4 questions
  2007-04-05 21:22 2 camlp4 questions Hendrik Tews
@ 2007-04-05 21:54 ` Martin Jambon
  2007-04-06  0:52 ` Nicolas Pouillard
  1 sibling, 0 replies; 3+ messages in thread
From: Martin Jambon @ 2007-04-05 21:54 UTC (permalink / raw)
  To: Hendrik Tews; +Cc: caml-list

On Thu, 5 Apr 2007, Hendrik Tews wrote:

> Hi,
>
> I am still reading the camlp4 sources:
>
> 1. Is there a special @loc quotation form? For instance in
>    camlp4/Camlp4Bin.ml line 141
>
>   [ <:sig_item@loc< # $n$ $str:s$ >> -> Some (loc, n, s)
>
>    What does it do? Or is ``sig_item@loc'' just the identifier of
>    the quotation expander?

I can answer this one: @x means "bind the location to x". Before you had
to extract the location explicitely using one of the MLast.loc_of_*
functions.

It's not done by default using _loc because of cases like this one:

match e1, e2 with
  <:expr< ...>>, <:expr< ... >> -> ...


Martin

--
Martin Jambon
http://martin.jambon.free.fr


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [Caml-list] 2 camlp4 questions
  2007-04-05 21:22 2 camlp4 questions Hendrik Tews
  2007-04-05 21:54 ` [Caml-list] " Martin Jambon
@ 2007-04-06  0:52 ` Nicolas Pouillard
  1 sibling, 0 replies; 3+ messages in thread
From: Nicolas Pouillard @ 2007-04-06  0:52 UTC (permalink / raw)
  To: Hendrik Tews; +Cc: caml-list

On 4/5/07, Hendrik Tews <H.Tews@cs.ru.nl> wrote:
> Hi,
>
> I am still reading the camlp4 sources:
>

[... an already answered question ...]

> 2. Camlp4Bin calls a cleaning pass before printing. The cleaner
>    does things like
>
>       <:expr< $e$; $ <:expr<>> $ >> -> self#expr e
>
>    What do these empty quotations ``<:expr<>>'' stand for? Are
>    these just the things that filters leave behind if they delete
>    a node?

Yes it can be some filters junks, but not only.
If you construct something like a sequence, a tuple, a sum type
(everything that was a list before), you will often want to use some
folding style and then these nil quotations will be helpful as initial
values.

At some other points these nil quotations are not useless (and so not
removed by that cleaner phase). For instance, if there is no guard in
a match that's represented by an nil expression:

<:match_case< $p$ -> $e$ >> = <:match_case< $p$ $when:<:expr<>>$ -> $e$ >>

Cheers,

-- 
Nicolas Pouillard


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2007-04-06  0:52 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-04-05 21:22 2 camlp4 questions Hendrik Tews
2007-04-05 21:54 ` [Caml-list] " Martin Jambon
2007-04-06  0:52 ` Nicolas Pouillard

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).