Download here - The Caml language
Transcript
Chapter 9
The toplevel system (ocaml)
This chapter describes the toplevel system for Objective Caml, that permits interactive use of the
Objective Caml system through a read-eval-print loop. In this mode, the system repeatedly reads
Caml phrases from the input, then typechecks, compile and evaluate them, then prints the inferred
type and result value, if any. The system prints a # (sharp) prompt before reading each phrase.
Input to the toplevel can span several lines. It is terminated by ;; (a double-semicolon). The
toplevel input consists in one or several toplevel phrases, with the following syntax:
toplevel-input ::= {toplevel-phrase} ;;
toplevel-phrase ::= definition
| expr
| # ident directive-argument
definition ::=
|
|
|
|
|
|
directive-argument ::=
|
|
|
let [rec] let-binding {and let-binding}
external value-name : typexpr = external-declaration
type-definition
exception-definition
module module-name [: module-type] = module-expr
module type modtype-name = module-type
open module-path
nothing
string-literal
integer-literal
value-path
A phrase can consist of a definition, similar to those found in implementations of compilation
units or in struct . . . end module expressions. The definition can bind value names, type names,
an exception, a module name, or a module type name. The toplevel system performs the bindings,
then prints the types and values (if any) for the names thus defined.
A phrase may also consist in a open directive (see section 6.11), or a value expression (section 6.7). Expressions are simply evaluated, without performing any bindings, and the value of the
expression is printed.
141
Related documents
The Objective Caml system release 3.08
The Objective Caml system release 3.00 - The Caml language
The Objective Caml system release 3.01 - The Caml language
The Objective Caml system release 2.04 - The Caml language
The Objective Caml system release 2.02 - The Caml language
OCaml 4 Reference Guide
GODI User`s Manual
The Caml Light system release 0.74 - The Caml language
User`s manual in PDF - The Caml language
Mode d`emploi Emacs, complément Environnement, suite
Manual - Ocamlviz
Lucid Synchrone Manual