The unpac monorepo manager self-hosting as a monorepo using unpac
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

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

authored by

Greta Yorsh and committed by
GitHub
5410d0c5 efac7902

+7 -7
+7 -7
manual/manual/cmds/intf-c.etex
··· 23 23 \end{alltt} 24 24 This defines the value name \var{name} as a function with type 25 25 \var{type} that executes by calling the given C function. 26 - For instance, here is how the "int_of_string" primitive is declared in the 26 + For instance, here is how the "seek_in" primitive is declared in the 27 27 standard library module "Stdlib": 28 28 \begin{verbatim} 29 - external int_of_string : string -> int = "caml_int_of_string" 29 + external seek_in : in_channel -> int -> unit = "caml_ml_seek_in" 30 30 \end{verbatim} 31 31 Primitives with several arguments are always curried. The C function 32 32 does not necessarily have the same name as the ML function. ··· 51 51 The arity (number of arguments) of a primitive is automatically 52 52 determined from its OCaml type in the "external" declaration, by 53 53 counting the number of function arrows in the type. For instance, 54 - "input" above has arity 4, and the "input" C function is called with 55 - four arguments. Similarly, 54 + "seek_in" above has arity 2, and the "caml_ml_seek_in" C function 55 + is called with two arguments. Similarly, 56 56 \begin{verbatim} 57 - external input2 : in_channel * bytes * int * int -> int = "input2" 57 + external seek_in_pair: in_channel * int -> unit = "caml_ml_seek_in_pair" 58 58 \end{verbatim} 59 - has arity 1, and the "input2" C function receives one argument (which 60 - is a quadruple of OCaml values). 59 + has arity 1, and the "caml_ml_seek_in_pair" C function receives one argument 60 + (which is a pair of OCaml values). 61 61 62 62 Type abbreviations are not expanded when determining the arity of a 63 63 primitive. For instance,