From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@sympa.inria.fr Delivered-To: caml-list@sympa.inria.fr 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 8E0657F9BB for ; Tue, 1 Jul 2014 19:06:31 +0200 (CEST) Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of philippe.veber@gmail.com) identity=pra; client-ip=74.125.82.173; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="philippe.veber@gmail.com"; x-sender="philippe.veber@gmail.com"; x-conformance=sidf_compatible Received-SPF: Pass (mail2-smtp-roc.national.inria.fr: domain of philippe.veber@gmail.com designates 74.125.82.173 as permitted sender) identity=mailfrom; client-ip=74.125.82.173; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="philippe.veber@gmail.com"; x-sender="philippe.veber@gmail.com"; x-conformance=sidf_compatible; x-record-type="v=spf1" Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of postmaster@mail-we0-f173.google.com) identity=helo; client-ip=74.125.82.173; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="philippe.veber@gmail.com"; x-sender="postmaster@mail-we0-f173.google.com"; x-conformance=sidf_compatible X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AnoBABPqslNKfVKtm2dsb2JhbABaDoNRWrxwiRUBgQUIFg8BAQEBAQYLCwkUKIQDAQEBAwESFRkBGx0BAwELBgUEBwYDAQIBLiEBAREBBQEUCAYTIogLAQMJCKBiao0ZgxCQGAoZJw1khUERAQUNjGuCFhEHBoQ9BZhogX6BSIwphCEYKYQwRDs X-IPAS-Result: AnoBABPqslNKfVKtm2dsb2JhbABaDoNRWrxwiRUBgQUIFg8BAQEBAQYLCwkUKIQDAQEBAwESFRkBGx0BAwELBgUEBwYDAQIBLiEBAREBBQEUCAYTIogLAQMJCKBiao0ZgxCQGAoZJw1khUERAQUNjGuCFhEHBoQ9BZhogX6BSIwphCEYKYQwRDs X-IronPort-AV: E=Sophos;i="5.01,582,1400018400"; d="scan'208";a="83174757" Received: from mail-we0-f173.google.com ([74.125.82.173]) by mail2-smtp-roc.national.inria.fr with ESMTP/TLS/RC4-SHA; 01 Jul 2014 19:06:30 +0200 Received: by mail-we0-f173.google.com with SMTP id t60so10076294wes.18 for ; Tue, 01 Jul 2014 10:06:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type; bh=V0wPUge36EfeoipCgj0YeMg2zomaVHATWDeLZdNALCA=; b=FuxCyIqdsdsadbKHJPAWL9p7BMT680rW4r/NNB5kbVRhf52FqM/6Mc52eibipRxh3/ gi81y3SC/afWzDUJdEmeJH1Qj1CFfX/RdyBJABR9LA+IHgf43ljnduHfqi7PeSFJcNR9 oeoi6Se+1p+9ycsbVYWcS7pUa74WR+PNw5cbBVjatT38p996Cu5c4lyyS/qJHtYPwP51 gTkFzfFlW7RzfHsObaVBGtIfe0bgB5gW1AvMbnb3TmD2LZT0WoURQn15IvPsqHgU8FNz jxdP+/kkqFckcmMtrr1Y9Avw8aAe7ve9O98Qpepx8+0Z0eKibr/CAUYbr/OfykWSgJP4 Vwhg== X-Received: by 10.180.91.81 with SMTP id cc17mr37444942wib.17.1404234385034; Tue, 01 Jul 2014 10:06:25 -0700 (PDT) MIME-Version: 1.0 Received: by 10.194.175.232 with HTTP; Tue, 1 Jul 2014 10:06:04 -0700 (PDT) In-Reply-To: References: From: Philippe Veber Date: Tue, 1 Jul 2014 19:06:04 +0200 Message-ID: To: David Sheets Cc: caml users Content-Type: multipart/alternative; boundary=f46d0438923db3937104fd24cb1b X-Validation-by: philippe.veber@gmail.com Subject: Re: [Caml-list] Fwd: Toplevel and syntax extension. --f46d0438923db3937104fd24cb1b Content-Type: text/plain; charset=ISO-8859-1 Thanks David! The first call fails with a syntax error on "with sexp": [pbil:~ 18:58]$cat rien.ml let () = try Topdirs.dir_directory (Sys.getenv "OCAML_TOPLEVEL_PATH") with Not_found -> () ;; #use "topfind";; #camlp4o;; #require " sexplib.syntax";; open Sexplib.Std;; type t = int with sexp;; [pbil:~ 18:58]$ocaml rien.ml File "rien.ml", line 12, characters 13-17: Error: Syntax error It seems like the sexp syntax extension is not loaded when the script is evaluated. But it's not really clear to me what going wrong... Cheers! ph. 2014-07-01 18:51 GMT+02:00 David Sheets : > On Tue, Jul 1, 2014 at 5:38 PM, Philippe Veber > wrote: > > Reposting this question here, just in case. > > > > ---------- Forwarded message ---------- > > From: Philippe Veber > > Date: 2014-06-28 21:32 GMT+02:00 > > Subject: Toplevel and syntax extension. > > To: ocaml_beginners@yahoogroups.com > > > > > > Dear camlers, > > > > Consider the following script: > > > > #use "topfind";; > > #camlp4o;; > > #require "sexplib.syntax";; > > > > open Sexplib.Std;; > > > > type t = int with sexp;; > > > > Saved as script.ml, the simple call: > > > > ocaml script.ml > > > > fails while the call: > > > > cat script.ml | ocaml > > > > succeeds. Any idea how I could fix the first call? > > How does the first call fail? A difference between the two is that, in > the second, the .ocamlinit file is used. If you are using opam with > ocamlfind installed via it, this file will contain your Topdirs setup. > You can try: > > let () = > try Topdirs.dir_directory (Sys.getenv "OCAML_TOPLEVEL_PATH") > with Not_found -> () > ;; > > at the top of your script (after hashbang but before directives). > > Hope this helps, > > David > --f46d0438923db3937104fd24cb1b Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable
Thanks David!

The first c= all fails with a syntax error on "with sexp":

[pbil:~ 18:5= 8]$cat rien.ml
let () =3D
=A0 try Topd= irs.dir_directory (Sys.getenv "OCAML_TOPLEVEL_PATH")
=A0 with Not_found -> ()
;;

#use "topfind";;
#cam= lp4o;;
#require " sexplib.syntax";;

open Sexplib.Std;;<= br>
type t =3D int with sexp;;

[pbil:~ 18:58]$ocaml rien.ml
File "rien.ml", line 12, character= s 13-17:
Error: Syntax error

It seems like the sexp syntax = extension is not loaded when the script is evaluated. But it's not real= ly clear to me what going wrong...

Cheers!
ph.
=A0


2014-07-01 18:51 GM= T+02:00 David Sheets <sheets@alum.mit.edu>:
On T= ue, Jul 1, 2014 at 5:38 PM, Philippe Veber <philippe.veber@gmail.com> wrote:
> Reposting this question here, just in case.
>
> ---------- Forwarded message ----------
> From: Philippe Veber <p= hilippe.veber@gmail.com>
> Date: 2014-06-28 21:32 GMT+02:00
> Subject: Toplevel and syntax extension.
> To: ocaml_beginners= @yahoogroups.com
>
>
> Dear camlers,
>
> Consider the following script:
>
> #use "topfind";;
> #camlp4o;;
> #require "sexplib.syntax";;
>
> open Sexplib.Std;;
>
> type t =3D int with sexp;;
>
> Saved as script.ml,= the simple call:
>
> ocaml script.ml
>
> fails while the call:
>
> cat script.ml | oca= ml
>
> succeeds. Any idea how I could fix the first call?

How does the first call fail? A difference between the two is t= hat, in
the second, the .ocamlinit file is used. If you are using opam with
ocamlfind installed via it, this file will contain your Topdirs setup.
You can try:

let () =3D
=A0 try Topdirs.dir_directory (Sys.getenv "OCAML_TOPLEVEL_PATH")<= br> =A0 with Not_found -> ()
;;

at the top of your script (after hashbang but before directives).

Hope this helps,

David

--f46d0438923db3937104fd24cb1b--