caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Caml-list] external & toplevel
@ 2006-01-26 16:56 Jonathan Roewen
  2006-01-27 14:09 ` Virgile Prevosto
  0 siblings, 1 reply; 2+ messages in thread
From: Jonathan Roewen @ 2006-01-26 16:56 UTC (permalink / raw)
  To: caml-list

Hi,

Is there a way to disallow external in the toplevel?

Jonathan


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [Caml-list] external & toplevel
  2006-01-26 16:56 [Caml-list] external & toplevel Jonathan Roewen
@ 2006-01-27 14:09 ` Virgile Prevosto
  0 siblings, 0 replies; 2+ messages in thread
From: Virgile Prevosto @ 2006-01-27 14:09 UTC (permalink / raw)
  To: caml-list

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


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2006-01-27 14:09 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-01-26 16:56 [Caml-list] external & toplevel Jonathan Roewen
2006-01-27 14:09 ` Virgile Prevosto

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).