(Introduced in Objective Caml 1.00)

As mentioned in section 9.7.2, the let rec binding construct, in addition to the definition of recursive functions, also supports a certain class of recursive definitions of non-functional values, such as

which binds name_{1} to the cyclic list 1::2::1::2::…, and
name_{2} to the cyclic list 2::1::2::1::…Informally, the class of accepted definitions consists of those
definitions where the defined names occur only inside function
bodies or as argument to a data constructor.

More precisely, consider the expression:

It will be accepted if each one of expr_{1} … expr_{n} is
statically constructive with respect to name_{1} … name_{n},
is not immediately linked to any of name_{1} … name_{n},
and is not an array constructor whose arguments have abstract type.

An expression e is said to be *statically constructive
with respect to* the variables name_{1} … name_{n} if at least
one of the following conditions is true:

- e has no free occurrence of any of name
_{1}… name_{n} - e is a variable
- e has the form fun … -> …
- e has the form function … -> …
- e has the form lazy ( … )
- e has one of the following forms, where each one of
expr
_{1}… expr_{m}is statically constructive with respect to name_{1}… name_{n}, and expr_{0}is statically constructive with respect to name_{1}… name_{n}, xname_{1}… xname_{m}:- let [rec] xname
_{1}= expr_{1}and … and xname_{m}= expr_{m}in expr_{0} - let module … in expr
_{1} - constr (expr
_{1}, … , expr_{m}) - `tag-name (expr
_{1}, … , expr_{m}) - [| expr
_{1}; … ; expr_{m}|] - { field
_{1}= expr_{1}; … ; field_{m}= expr_{m}} - { expr
_{1}with field_{2}= expr_{2}; … ; field_{m}= expr_{m}} where expr_{1}is not immediately linked to name_{1}… name_{n} - ( expr
_{1}, … , expr_{m}) - expr
_{1}; … ; expr_{m}

- let [rec] xname

An expression e is said to be *immediately linked to* the variable
name in the following cases:

- e is name
- e has the form expr
_{1}; … ; expr_{m}where expr_{m}is immediately linked to name - e has the form let [rec] xname
_{1}= expr_{1}and … and xname_{m}= expr_{m}in expr_{0}where expr_{0}is immediately linked to name or to one of the xname_{i}such that expr_{i}is immediately linked to name.

Copyright © 2022 Institut National de
Recherche en Informatique et en Automatique