<?xml version="1.0" encoding="ISO-8859-1"?>

<!DOCTYPE message PUBLIC
  "-//MLarc//DTD MLarc output files//EN"
  "../../mlarc.dtd"[
  <!ATTLIST message
    listname CDATA #REQUIRED
    title CDATA #REQUIRED
  >
]>

  <?xml-stylesheet href="../../mlarc.xsl" type="text/xsl"?>


<message 
  url="2002/12/be95aad281fdfa0b0e17d2aadce6fe33"
  from="Daniel de Rauglaudre &lt;daniel.de_rauglaudre@i...&gt;"
  author="Daniel de Rauglaudre"
  date="2002-12-10T17:38:21"
  subject="Re: [Caml-list] Camlp4: generating printers of types"
  prev="2002/12/a74ed3db4fc33553d8213466da24214a"
  next="2002/12/2d52df0ad599c2398d444ee33eeed595"
  prev-in-thread="2002/12/adca70ed0317d2ff1156d25d7bb3384b"
  next-in-thread="2002/12/78f7eb64b20320970621cfe5b9407fa8"
  prev-thread="2002/10/1dd4307f336f52923ec9c00bf50e6612"
  next-thread="2002/10/bd720bbf86918b2c2bc40fcc8d8f5f47"
  root="../../"
  period="month"
  listname="caml-list"
  title="Archives of the Caml mailing list">

<thread subject="[Caml-list] Camlp4: generating printers of types">
<msg 
  url="2002/10/911fcb8a222e666411b28b0649e3d30d"
  from="Daniel de Rauglaudre &lt;daniel.de_rauglaudre@i...&gt;"
  author="Daniel de Rauglaudre"
  date="2002-10-09T13:13:19"
  subject="[Caml-list] Camlp4: generating printers of types">
<msg 
  url="2002/12/bda14d3a04f2eedf91905a4eb42a9207"
  from="Ken Rose &lt;kenarose@e...&gt;"
  author="Ken Rose"
  date="2002-12-10T02:02:03"
  subject="Re: [Caml-list] Camlp4: generating printers of types">
<msg 
  url="2002/12/38d206434ca03422a3daee596c95db10"
  from="Daniel de Rauglaudre &lt;daniel.de_rauglaudre@i...&gt;"
  author="Daniel de Rauglaudre"
  date="2002-12-10T12:25:03"
  subject="Re: [Caml-list] Camlp4: generating printers of types">
<msg 
  url="2002/12/adca70ed0317d2ff1156d25d7bb3384b"
  from="Ken Rose &lt;kenarose@e...&gt;"
  author="Ken Rose"
  date="2002-12-10T15:33:32"
  subject="Re: [Caml-list] Camlp4: generating printers of types">
<msg 
  url="2002/12/be95aad281fdfa0b0e17d2aadce6fe33"
  from="Daniel de Rauglaudre &lt;daniel.de_rauglaudre@i...&gt;"
  author="Daniel de Rauglaudre"
  date="2002-12-10T17:38:21"
  subject="Re: [Caml-list] Camlp4: generating printers of types">
</msg>
</msg>
</msg>
<msg 
  url="2002/12/78f7eb64b20320970621cfe5b9407fa8"
  from="Damien Doligez &lt;damien.doligez@i...&gt;"
  author="Damien Doligez"
  date="2002-12-10T13:21:15"
  subject="Re: [Caml-list] Camlp4: generating printers of types">
</msg>
</msg>
<msg 
  url="2002/10/c2f4146f681d505fc6e36fd0892119d5"
  from="Markus Mottl &lt;markus@o...&gt;"
  author="Markus Mottl"
  date="2002-10-09T17:18:14"
  subject="Re: [Caml-list] Camlp4: generating printers of types">
</msg>
<msg 
  url="2002/10/6b5af3e32f8ae3e379720ca547b582df"
  from="Ken Rose &lt;kenarose@e...&gt;"
  author="Ken Rose"
  date="2002-10-25T19:20:41"
  subject="Re: [Caml-list] Camlp4: generating printers of types">
<msg 
  url="2002/10/e90a6df400ab02125298d0c75314986e"
  from="Chris Hecker &lt;checker@d...&gt;"
  author="Chris Hecker"
  date="2002-10-25T20:02:23"
  subject="Re: [Caml-list] Camlp4: generating printers of types">
</msg>
<msg 
  url="2002/10/b87035709e416e656037bec29d7ea9c8"
  from="Daniel de Rauglaudre &lt;daniel.de_rauglaudre@i...&gt;"
  author="Daniel de Rauglaudre"
  date="2002-10-26T00:11:55"
  subject="Re: [Caml-list] Camlp4: generating printers of types">
</msg>
</msg>
</msg>
</thread>

<contents>
Hi,

On Tue, Dec 10, 2002 at 07:33:23AM -0800, Ken Rose wrote:

&gt; and so on into gen_print_type.  Or do I not understand what $uid:x$
&gt; does?

If x is a string &lt;:expr&lt; $uid:x$ &gt;&gt; produces "the uppercase identifier
named by the value of x". If x is "Foo", this produces the identifier
Foo. Notice that it works even if x does not contain an uppercase
identifier: OCaml with interpret it as a module name or as a
constructor name (depending on its position), whatever its value.

Sorry, for your Baz.Baz.t, you need your &lt;:ctyp&lt; $uid:m2$.$uid:m$.$lid:s$ &gt;&gt;
The better is to use an iterator, or use the recursion to treat the
general case.

&gt; &gt; In Revised syntax, they are like in normal syntax, but the parentheses
&gt; &gt; are compulsory.
&gt; 
&gt; Here, I want to match 
&gt; type t = int * int
&gt; within gen_one_print_fun, to produce a printer instead of "failwith...".

In Normal syntax, you can write "int * int" but inside the predefined
quotations of AST, you have to use the Revised syntax. See the chapter
about it in the reference manual.

You must write it &lt;:ctyp&lt; (int * int) &gt;&gt;. And if tl is a list of ctyp,
you can obtain the type tuple of this list of types with:
    &lt;:ctyp&lt; ($list:tl$) &gt;&gt;

See the chapter about AST quotations.

&gt; &gt; This message of OCaml just means that there are syntactic restrictions
&gt; &gt; of the "let rec". In this case, you should produce either a "let" without
&gt; &gt; "rec" or, an eta extension: "let rec print_t x = print_int x".
&gt; 
&gt; I'd suspected that, though I'm still curious as to why that's so. 

Damien Doligez answered you on that point; this is typing and
therefore not the work of Camlp4.

&gt; Still, what I really want is a generally useful tool to produce these
&gt; useful functions, without having to spend too much time right now
&gt; learning camlp4.  It's for my regular work, where I'm building a
&gt; compiler for a DSL.  I don't understand camlp4 well enough to know how
&gt; to suppress the "rec", and I'm hoping to avoid learning, at least for a
&gt; while.  It's a great tool, but I have only so much time.

Well, if you don't have time to look at it, I can help.

-- 
Daniel de RAUGLAUDRE
http://cristal.inria.fr/~ddr/
-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners

</contents>

</message>

