* camlp4: How to make a record expression w/o useless "with"
@ 2008-08-11 16:49 Richard Jones
2008-08-12 17:37 ` [Caml-list] " Richard Jones
0 siblings, 1 reply; 2+ messages in thread
From: Richard Jones @ 2008-08-11 16:49 UTC (permalink / raw)
To: caml-list
I have some code like the minimal example below. Notice the
'{ () with ... }'
record expression. If I remove the '() with' part, it fails to
compile.
Now the problem is that I'm actually using camlp4 to generate code
which gets saved in an ml file. In other words I'm using
'Printers.OCaml.print_implem' to print out the final code. The
useless '() with' causes a non-fatal but annoying warning (X) when the
generated code is compiled later on.
How can I get rid of it? According to
http://brion.inria.fr/gallium/index.php/Abstract_Syntax_Tree
the version without the useless '() with' ought to work, so maybe this
is a camlp4 bug?
This is OCaml 3.10.2.
------------------------------------------------------------
open Camlp4.PreCast
open Syntax
let _loc = Loc.ghost
let rbs =
<:rec_binding< foo = bar ; baz = quux >>
let record = <:expr< { () with $rbs$ } >>
------------------------------------------------------------
Rich.
--
Richard Jones
Red Hat
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [Caml-list] camlp4: How to make a record expression w/o useless "with"
2008-08-11 16:49 camlp4: How to make a record expression w/o useless "with" Richard Jones
@ 2008-08-12 17:37 ` Richard Jones
0 siblings, 0 replies; 2+ messages in thread
From: Richard Jones @ 2008-08-12 17:37 UTC (permalink / raw)
To: caml-list
On Mon, Aug 11, 2008 at 05:49:25PM +0100, Richard Jones wrote:
> I have some code like the minimal example below. Notice the
> '{ () with ... }'
> record expression. If I remove the '() with' part, it fails to
> compile.
For reference, Bluestorm found an answer to my question, by building
the AST explicitly:
let build_record _loc rbs =
Ast.ExRec (_loc, rbs, Ast.ExNil _loc)
Rich.
--
Richard Jones
Red Hat
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2008-08-12 17:37 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-08-11 16:49 camlp4: How to make a record expression w/o useless "with" Richard Jones
2008-08-12 17:37 ` [Caml-list] " Richard Jones
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox