From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail3-relais-sop.national.inria.fr (mail3-relais-sop.national.inria.fr [192.134.164.104]) by sympa.inria.fr (Postfix) with ESMTPS id 3EE327FCCB for ; Sun, 3 May 2015 04:28:24 +0200 (CEST) Received-SPF: None (mail3-smtp-sop.national.inria.fr: no sender authenticity information available from domain of carette@mcmaster.ca) identity=pra; client-ip=130.113.64.127; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="carette@mcmaster.ca"; x-sender="carette@mcmaster.ca"; x-conformance=sidf_compatible Received-SPF: None (mail3-smtp-sop.national.inria.fr: no sender authenticity information available from domain of carette@mcmaster.ca) identity=mailfrom; client-ip=130.113.64.127; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="carette@mcmaster.ca"; x-sender="carette@mcmaster.ca"; x-conformance=sidf_compatible Received-SPF: None (mail3-smtp-sop.national.inria.fr: no sender authenticity information available from domain of postmaster@pinegw01.uts.mcmaster.ca) identity=helo; client-ip=130.113.64.127; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="carette@mcmaster.ca"; x-sender="postmaster@pinegw01.uts.mcmaster.ca"; x-conformance=sidf_compatible X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A0DaAQBNh0VVbX9AcYJcg19cgx3EIIYMAoF4EAEBAQEBAQERDQsJCSEuhCEBAQQjDwEFQAEQCxgCAgUWCwICCQMCAQIBDzYGDQEFAgEBF4d8AxGyJ41EDYUeAQEBAQEBBAEBAQEBARyBIYoYgk2CBTMHgmiBRQEElh6EbIM2hWaHd4ZgggiCK1OCRQEBAQ X-IPAS-Result: A0DaAQBNh0VVbX9AcYJcg19cgx3EIIYMAoF4EAEBAQEBAQERDQsJCSEuhCEBAQQjDwEFQAEQCxgCAgUWCwICCQMCAQIBDzYGDQEFAgEBF4d8AxGyJ41EDYUeAQEBAQEBBAEBAQEBARyBIYoYgk2CBTMHgmiBRQEElh6EbIM2hWaHd4ZgggiCK1OCRQEBAQ X-IronPort-AV: E=Sophos;i="5.13,358,1427752800"; d="scan'208";a="114315152" Received: from pinegw01.uts.mcmaster.ca ([130.113.64.127]) by mail3-smtp-sop.national.inria.fr with ESMTP/TLS/DHE-RSA-AES256-SHA; 03 May 2015 04:28:22 +0200 Received: from pinegw03.uts.mcmaster.ca (pinegw03.UTS.McMaster.CA [130.113.64.132]) by pinegw01.uts.mcmaster.ca (8.14.4/8.14.4) with ESMTP id t432SIV9013207 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Sat, 2 May 2015 22:28:18 -0400 Received: from cgpsrv2.cis.mcmaster.ca (univmail.CIS.McMaster.CA [130.113.64.46]) by pinegw03.uts.mcmaster.ca (8.14.4/8.14.4) with ESMTP id t432SILW027270; Sat, 2 May 2015 22:28:18 -0400 Received: from [99.236.219.219] (account carette@univmail.cis.mcmaster.ca HELO [192.168.2.104]) by cgpsrv2.cis.mcmaster.ca (CommuniGate Pro SMTP 5.2.12) with ESMTPSA id 558470828; Sat, 02 May 2015 22:28:18 -0400 Message-ID: <554587C0.1070500@mcmaster.ca> Date: Sat, 02 May 2015 22:28:16 -0400 From: Jacques Carette Organization: McMaster University User-Agent: Mozilla/5.0 (Windows NT 6.2; WOW64; rv:31.0) Gecko/20100101 Thunderbird/31.6.0 MIME-Version: 1.0 To: =?UTF-8?B?w5ZtZXIgU2luYW4gQcSfYWNhbg==?= CC: OCaml Mailing List References: <20150501112114.1C8DFC382A@www1.g3.pair.com> <1430496980.1158661.261513285.08E1920C@webmail.messagingengine.com> <1430498707.1164081.261525093.47AD6B00@webmail.messagingengine.com> <5545384D.40803@mcmaster.ca> In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit X-PMX-Version-Mac: 6.0.3.2322014, Antispam-Engine: 2.7.2.2107409, Antispam-Data: 2015.5.3.21819 X-PerlMx-Spam: Gauge=XXIIIIIIII, Probability=28%, Report=' SXL_IP_DYNAMIC 3, HTML_00_01 0.05, HTML_00_10 0.05, BODY_SIZE_3000_3999 0, BODY_SIZE_5000_LESS 0, BODY_SIZE_7000_LESS 0, DATE_TZ_NA 0, REFERENCES 0, __ANY_URI 0, __BOUNCE_CHALLENGE_SUBJ 0, __BOUNCE_NDR_SUBJ_EXEMPT 0, __CT 0, __CTE 0, __CT_TEXT_PLAIN 0, __FORWARDED_MSG 0, __FRAUD_BODY_WEBMAIL 0, __FRAUD_WEBMAIL 0, __HAS_FROM 0, __HAS_MSGID 0, __IN_REP_TO 0, __MIME_TEXT_ONLY 0, __MIME_VERSION 0, __MOZILLA_MSGID 0, __MOZILLA_USER_AGENT 0, __REFERENCES 0, __SANE_MSGID 0, __SUBJ_ALPHA_END 0, __SUBJ_ALPHA_NEGATE 0, __URI_NO_PATH 0, __URI_NO_WWW 0, __URI_NS , __USER_AGENT 0' X-Spam-Flag: NO Subject: Re: [Caml-list] Problems with printing MetaOCaml generated code But that's the whole point: you are not persisting a value, you are persisting a local variable. In the context of staging, a variable and its value are radically different, unlike in the traditional functional programming context, where this difference can be safely and harmlessly blurred. If you want to persist "named values", then give globally accessible names to these values [which I believe others have already told you]. If you want to persist values, then use my solution or a variant of that. Jacques On 2015-05-02 9:56 PM, Ömer Sinan Ağacan wrote: > That's not a solution. I should be able to generate some values in > code generation time and persist them in code values, that's the whole > point here. > > 2015-05-02 16:49 GMT-04:00 Jacques Carette : >> 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 : >>>>> 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: >>>> >>>> .. >>>> >>>> My main question is that it should serialize p' here, but it doesn't. I'm >>>> trying to understand why. >>