From: Virgile Prevosto <virgile.prevosto@m4x.org>
To: caml-list@yquem.inria.fr
Subject: Re: [Caml-list] external & toplevel
Date: Fri, 27 Jan 2006 15:09:43 +0100 [thread overview]
Message-ID: <20060127150943.335c4217@localhost.localdomain> (raw)
In-Reply-To: <ad8cfe7e0601260856r3624420fm2526b0a928708012@mail.gmail.com>
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
prev parent reply other threads:[~2006-01-27 14:09 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-01-26 16:56 Jonathan Roewen
2006-01-27 14:09 ` Virgile Prevosto [this message]
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=20060127150943.335c4217@localhost.localdomain \
--to=virgile.prevosto@m4x.org \
--cc=caml-list@yquem.inria.fr \
/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