From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) by sympa.inria.fr (Postfix) with ESMTPS id 039CE7FCCB for ; Thu, 30 Apr 2015 21:52:53 +0200 (CEST) Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of carette@mcmaster.ca) identity=pra; client-ip=130.113.64.127; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="carette@mcmaster.ca"; x-sender="carette@mcmaster.ca"; x-conformance=sidf_compatible Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of carette@mcmaster.ca) identity=mailfrom; client-ip=130.113.64.127; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="carette@mcmaster.ca"; x-sender="carette@mcmaster.ca"; x-conformance=sidf_compatible Received-SPF: None (mail2-smtp-roc.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=mail2-smtp-roc.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: A0CPAQCnh0JVbX9AcYJcg19cgxvCPoFPhggCghATAQEBAQEBARENBgUJCSEuhCEBAQQjDwEFQBELGAICBRYLAgIJAwIBAgFFBgEMCAEBiCcNtQSTVwEBAQcCAR+BIYoXgmuCIYJogUUFlXOIH4Vejj+CKhyBbVOCRQEBAQ X-IPAS-Result: A0CPAQCnh0JVbX9AcYJcg19cgxvCPoFPhggCghATAQEBAQEBARENBgUJCSEuhCEBAQQjDwEFQBELGAICBRYLAgIJAwIBAgFFBgEMCAEBiCcNtQSTVwEBAQcCAR+BIYoXgmuCIYJogUUFlXOIH4Vejj+CKhyBbVOCRQEBAQ X-IronPort-AV: E=Sophos;i="5.11,678,1422918000"; d="scan'208";a="138382037" Received: from pinegw01.uts.mcmaster.ca ([130.113.64.127]) by mail2-smtp-roc.national.inria.fr with ESMTP/TLS/DHE-RSA-AES256-SHA; 30 Apr 2015 21:52:49 +0200 Received: from pinegw04.uts.mcmaster.ca (pinegw04.UTS.McMaster.CA [130.113.128.58]) by pinegw01.uts.mcmaster.ca (8.14.4/8.14.4) with ESMTP id t3UJqjj8027835 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Thu, 30 Apr 2015 15:52:45 -0400 Received: from cgpsrv2.cis.mcmaster.ca (univmail.CIS.McMaster.CA [130.113.64.46]) by pinegw04.uts.mcmaster.ca (8.14.4/8.14.4) with ESMTP id t3UJqjZ3001331; Thu, 30 Apr 2015 15:52:45 -0400 Received: from [172.17.145.17] (account carette@univmail.cis.mcmaster.ca HELO JacquesMacAir.local) by cgpsrv2.cis.mcmaster.ca (CommuniGate Pro SMTP 5.2.12) with ESMTPSA id 558245900; Thu, 30 Apr 2015 15:52:45 -0400 Message-ID: <5542880D.2060008@mcmaster.ca> Date: Thu, 30 Apr 2015 15:52:45 -0400 From: Jacques Carette User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.9; rv:31.0) Gecko/20100101 Thunderbird/31.6.0 MIME-Version: 1.0 To: =?UTF-8?B?w5ZtZXIgU2luYW4gQcSfYWNhbg==?= , OCaml Mailing List References: 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.4.30.194220 X-PerlMx-Spam: Gauge=IIIIIIII, Probability=8%, Report=' RCVD_FROM_IP_DATE 0.1, 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, __CP_NOT_1 0, __CP_URI_IN_BODY 0, __CT 0, __CTE 0, __CT_TEXT_PLAIN 0, __FORWARDED_MSG 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_MAILTO 0, __URI_NO_WWW 0, __URI_NS , __USER_AGENT 0' X-Spam-Flag: NO Subject: Re: [Caml-list] Problems with printing MetaOCaml generated code You will have some difficulties printing complex closures, especially when they refer to values built in the generator (CSPs) which are not simple values (strings, integers, etc). Sometimes, very simple changes to the generator can allow closures and CSPs to be printable or not -- without very specific examples, I can't help (it's been a few years since I dug into this deeply). I have been able to print rather complex, large codes with metaocaml. But one has to structure the generator rather carefully to ensure this possibility. Jacques On 2015-04-30 14:36 , Ömer Sinan Ağacan wrote: > Hi all, > > I'm working on a MetaOCaml program and I want to save generated programs to > files instead of directly running them within the same program using > `Runcode.(.!)` or `Runcode.run`. The problem is MetaOCaml never prints > generated code, it's always failing with `Warning 22: The CSP value is a > closure or too deep to serialize`. > > I can't see anything related in it's web page: > http://okmij.org/ftp/ML/MetaOCaml.html. What I understand from that page is > once I have a closed code, I should be able to print it no matter what. > However in my experience even the simplest realistic MetaOCaml program fails to > generate the code because of this error I mentioned above. > > (One thing to note here is that my program generates the code on a couple of > inputs, but fails in most of them with this error message.) > > In "Many ways to run the code" section it's said that "Since closed code is > essentially OCaml AST, after closing the generated code, the user may examine > and `run' it in many ways. One way of running the code is printing it." and > then it lists some API functions for printing. In my experience none of them > really work, I have closed code which I successfully closed using > `Runcode.close_code`, but `print_closed_code` is still failing with the error, > and `print_code_as_ast` is printing something that definitely doesn't look like > an AST for any imaginable programming language.(okay... I might have > exaggerated a bit, but it's definitely not OCaml AST and it contains some > references to generator program source, like "Generator.ml[248]" for example) > > One relevant thing I could find in the documentation is this: "If the code > includes CSP only as literals or external references (and any code can be > arranged that way), the code can be stored into a file and then passed to > ocamlopt." If we remove this sentence from the documentation, I don't think it > mentions about any possible failures in code printing. > > So now that I've expressed my frustration about this, I guess my main question > is: In what cases does MetaOCaml prints generated code? In what cases it > doesn't? Note that it fails to generate code even after calling > `print_closed_code (close_code ...)`, so being closed or not doesn't seem very > relevent here. Is this a bug in MetaOCaml? Are there any workarounds? Any ideas > what am I doing wrong? > > Thanks in advance for any answers, > > Ömer >