caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Oleg <>
Subject: [Caml-list] ANN: BER MetaOCaml N111, for OCaml 4.11.1
Date: Wed, 7 Oct 2020 15:29:24 +0900
Message-ID: <20201007062924.GA1995@Melchior.localnet> (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.

                 reply	other threads:[~2020-10-07  6:25 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20201007062924.GA1995@Melchior.localnet \ \ \

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

caml-list - the Caml user's mailing list

This inbox may be cloned and mirrored by anyone:

	git clone --mirror
	git clone --mirror

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V1 caml-list caml-list/ \
	public-inbox-index caml-list

Example config snippet for mirrors.
Newsgroup available over NNTP:

AGPL code for this site: git clone