* [Caml-list] ANN: BER MetaOCaml N111, for OCaml 4.11.1
@ 2020-10-07 6:29 Oleg
0 siblings, 0 replies; only message in thread
From: Oleg @ 2020-10-07 6:29 UTC (permalink / raw)
BER MetaOCaml N111 is a strict superset of OCaml 4.11.1 for ``writing
programs that generate programs''. BER MetaOCaml adds to OCaml the
type of code values (denoting ``program code'', or future-stage
computations), and two basic constructs to build them: quoting and
splicing. The generated code can be printed, stored in a file -- or
compiled and linked-back to the running program, thus implementing
run-time code optimization. A well-typed BER MetaOCaml program
generates only well-scoped and well-typed programs: The generated code
shall compile without type errors. Staging-annotation--free BER
MetaOCaml is identical to OCaml; BER MetaOCaml can link to any
OCaml-compiled library (and vice versa); findlib and other tools can
be used with BER MetaOCaml as they are, in their binary form.
BER MetaOCaml N111 is a superset of the recently released OCaml
4.11.1. The significant addition is let rec insertion: the facility to
generate groups of mutually recursive definitions whose size is not
statically known. It is now possible to control the scope of
let-insertion, which is often necessary when the let-bound expression
is effectful. The well-scopedness guarantee is still
maintained. Offshoring got more polish.
As the simplest illustration of let rec insertion, the specialization
of the Ackermann function
let rec ack m n =
if m = 0 then n+1 else
if n = 0 then ack (m-1) 1 else
ack (m-1) (ack m (n-1))
to m=2 produces the following code
val sac2 : (int -> int) code = .<
let rec h_6 n_7 = n_7 + 1
and h_4 n_5 = if n_5 = 0 then h_6 1 else h_6 (h_4 (n_5 - 1))
and h_2 n_3 = if n_3 = 0 then h_4 1 else h_4 (h_2 (n_3 - 1)) in h_2>.
For more explanations, please see
which now has dedicated sections on let rec insertions and offshoring.
See also ChangeLog and NOTES.txt in the BER MetaOCaml distribution.
BER MetaOCaml N111 should be available though OPAM, hopefully soon.
In the meanwhile, it is available as a set of patches to the
OCaml 4.11.1 distribution.
See the INSTALL document in that archive. You need the source
distribution of OCaml 4.11.1.
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2020-10-07 6:25 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-07 6:29 [Caml-list] ANN: BER MetaOCaml N111, for OCaml 4.11.1 Oleg
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).