Fix example of external C function in the manual (#9977)

master
Greta Yorsh 2020-10-14 15:31:33 +01:00 committed by GitHub
parent efac790249
commit 5410d0c5d3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 7 deletions

View File

@ -23,10 +23,10 @@ User primitives are declared in an implementation file or
\end{alltt} \end{alltt}
This defines the value name \var{name} as a function with type This defines the value name \var{name} as a function with type
\var{type} that executes by calling the given C function. \var{type} that executes by calling the given C function.
For instance, here is how the "int_of_string" primitive is declared in the For instance, here is how the "seek_in" primitive is declared in the
standard library module "Stdlib": standard library module "Stdlib":
\begin{verbatim} \begin{verbatim}
external int_of_string : string -> int = "caml_int_of_string" external seek_in : in_channel -> int -> unit = "caml_ml_seek_in"
\end{verbatim} \end{verbatim}
Primitives with several arguments are always curried. The C function Primitives with several arguments are always curried. The C function
does not necessarily have the same name as the ML function. does not necessarily have the same name as the ML function.
@ -51,13 +51,13 @@ modules from libraries at link-time.
The arity (number of arguments) of a primitive is automatically The arity (number of arguments) of a primitive is automatically
determined from its OCaml type in the "external" declaration, by determined from its OCaml type in the "external" declaration, by
counting the number of function arrows in the type. For instance, counting the number of function arrows in the type. For instance,
"input" above has arity 4, and the "input" C function is called with "seek_in" above has arity 2, and the "caml_ml_seek_in" C function
four arguments. Similarly, is called with two arguments. Similarly,
\begin{verbatim} \begin{verbatim}
external input2 : in_channel * bytes * int * int -> int = "input2" external seek_in_pair: in_channel * int -> unit = "caml_ml_seek_in_pair"
\end{verbatim} \end{verbatim}
has arity 1, and the "input2" C function receives one argument (which has arity 1, and the "caml_ml_seek_in_pair" C function receives one argument
is a quadruple of OCaml values). (which is a pair of OCaml values).
Type abbreviations are not expanded when determining the arity of a Type abbreviations are not expanded when determining the arity of a
primitive. For instance, primitive. For instance,