Mailing list for all users of the OCaml language and system.
 help / color / mirror / Atom feed
From: Jacques Carette <carette@mcmaster.ca>
To: "Ömer Sinan Ağacan" <omeragacan@gmail.com>,
	"OCaml Mailing List" <caml-list@inria.fr>
Subject: Re: [Caml-list] Problems with printing MetaOCaml generated code
Date: Sat, 02 May 2015 16:49:17 -0400	[thread overview]
Message-ID: <5545384D.40803@mcmaster.ca> (raw)
In-Reply-To: <CAMQQO3k9MXTnNqn_fG49GSO-pQJba2cOziwwiUzrSJDyhZ6FLQ@mail.gmail.com>

try instead
    let stx1 = .< A >. in
and then
    print_code std_formatter .< .~stx1 >. ;

That ought to work as you wish.

Jacques

On 2015-05-02 2:45 PM, Ömer Sinan Ağacan wrote:
> In case anyone's still interested, I produced a very simple example that
> demonstrates the issue:
>
>    ➜  metaocaml_serialization_issue git:(master) ✗ ls
>    Main.ml  Syntax.ml
>    ➜  metaocaml_serialization_issue git:(master) ✗ cat Syntax.ml
>    type stx =
>      | A
>      | B of stx
>      | C of (stx * stx)
>    ➜  metaocaml_serialization_issue git:(master) ✗ cat Main.ml
>    open Format
>    open Print_code
>    open Runcode
>    open Syntax
>
>    let _ =
>      let stx1 = A in
>      let stx2 = B A in
>      let stx3 = C (A, A) in
>
>      print_code std_formatter .< stx1 >.;
>      print_code std_formatter .< stx2 >.;
>      print_code std_formatter .< stx3 >.;
>
>      print_closed_code std_formatter (close_code .< stx1 >.);
>      print_closed_code std_formatter (close_code .< stx2 >.);
>      print_closed_code std_formatter (close_code .< stx3 >.);
>    ➜  metaocaml_serialization_issue git:(master) ✗ metaocamlc Syntax.ml -c
>    ➜  metaocaml_serialization_issue git:(master) ✗ metaocamlc
> Syntax.cmo Main.ml -o main
>    ➜  metaocaml_serialization_issue git:(master) ✗ ./main
>    .<(* CSP stx1 *) Obj.magic 0>. .<(* CSP stx2 *)>. .<(* CSP stx3 *)>. .<
>    (* CSP stx1 *) Obj.magic 0>. .<(* CSP stx2 *)>. .<(* CSP stx3 *)>.
>    ➜  metaocaml_serialization_issue git:(master) ✗
>
>
> 2015-05-01 12:53 GMT-04:00 Ömer Sinan Ağacan <omeragacan@gmail.com>:
>>> You can't serialize `eval_ref` as `eval_ref` because that is a local
>>> identifier. If you print out `eval_ref` into some other ml file and compiler
>>> it, it is going to give an "Unbound identifier eval_ref" error.
>> That's true. Just to make sure and make the output more clear, I moved the
>> relevant code to another module, and now it's printing this:
>>
>> .<Unlambda.eval_ref (* CSP p' *) []>.
>>
>> My main question is that it should serialize p' here, but it doesn't. I'm
>> trying to understand why.


  reply	other threads:[~2015-05-02 20:49 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-04-30 18:36 Ömer Sinan Ağacan
2015-04-30 19:52 ` Jacques Carette
2015-04-30 20:25   ` Ömer Sinan Ağacan
2015-04-30 20:57     ` Ömer Sinan Ağacan
2015-04-30 21:35       ` Jeremy Yallop
2015-05-01 11:21       ` oleg
2015-05-01 14:34         ` Ömer Sinan Ağacan
2015-05-01 16:16           ` Leo White
2015-05-01 16:41             ` Ömer Sinan Ağacan
2015-05-01 16:45               ` Leo White
2015-05-01 16:53                 ` Ömer Sinan Ağacan
2015-05-02 18:45                   ` Ömer Sinan Ağacan
2015-05-02 20:49                     ` Jacques Carette [this message]
2015-05-03  1:56                       ` Ömer Sinan Ağacan
2015-05-03  2:28                         ` Jacques Carette
2015-05-03  3:19                           ` Ömer Sinan Ağacan
2015-05-03  8:40                             ` Gabriel Scherer
2015-05-03 14:28                               ` Ömer Sinan Ağacan
2015-05-03 15:24                                 ` Leo White
2015-05-03 15:50                                   ` Ömer Sinan Ağacan
2015-05-06  9:50           ` oleg
2015-05-06 15:58             ` Jeremy Yallop
2015-05-06 16:45               ` Yotam Barnoy

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=5545384D.40803@mcmaster.ca \
    --to=carette@mcmaster.ca \
    --cc=caml-list@inria.fr \
    --cc=omeragacan@gmail.com \
    /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