From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by yquem.inria.fr (Postfix) with ESMTP id A894FBBBB for ; Fri, 27 Jan 2006 15:09:35 +0100 (CET) Received: from localhost.localdomain (dhcp-rocq-166.inria.fr [128.93.62.166]) by concorde.inria.fr (8.13.0/8.13.0) with ESMTP id k0RE9ZZY014482 for ; Fri, 27 Jan 2006 15:09:35 +0100 Date: Fri, 27 Jan 2006 15:09:43 +0100 From: Virgile Prevosto To: caml-list@yquem.inria.fr Subject: Re: [Caml-list] external & toplevel Message-ID: <20060127150943.335c4217@localhost.localdomain> In-Reply-To: References: X-Mailer: Sylpheed-Claws 1.9.100 (GTK+ 2.8.10; i486-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Miltered: at concorde with ID 43DA299F.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; caml-list:01 toplevel:01 toplevel:01 camlp:01 camlp:01 cmo:01 pcaml:01 lident:01 ctyp:01 ctyp:01 ocamlmktop:01 ocaml:01 -pp:01 cmo:01 ocaml:01 X-Spam-Checker-Version: SpamAssassin 3.0.3 (2005-04-27) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.1 required=5.0 tests=FORGED_RCVD_HELO autolearn=disabled version=3.0.3 Hello Jonathan, Le ven 27 jan 2006 05:56:31 CET, Jonathan Roewen a écrit: > Is there a way to disallow external in the toplevel? > I'm not too sure I really understand your question, but if you want to prevent an user from writing an external definition in the toplevel, a camlp4 "contraction" could do it: ------------------ wo_external.ml ---------------- (* use these directives for interactive use #load "camlp4o.cma";; #load "pa_extend.cmo";; *) open Pcaml;; open Pa_o;; DELETE_RULE str_item: "external"; LIDENT; ":"; ctyp; "="; LIST1 STRING END;; DELETE_RULE str_item: "external"; "("; operator_rparen ; ":"; ctyp; "="; LIST1 STRING END;; ------------------------------------------- ocamlmktop -o ocaml_wo_external -pp "camlp4o pa_extend.cmo" \ -I +camlp4 camlp4o.cma wo_external.ml ./ocaml_wo_external Objective Caml version 3.09.1 Camlp4 Parsing version 3.09.1 # external (+++) : int -> int -> int= "%addint";; Toplevel input: # external (+++) : int -> int -> int= "%addint";; ^^^^^^^^ Parse error: illegal begin of top_phrase # external f: 'a -> 'a = "%identity";; Toplevel input: # external f: 'a -> 'a = "%identity";; ^^^^^^^^ -- E tutto per oggi, a la prossima volta Virgile