Mailing list for all users of the OCaml language and system.
 help / color / mirror / Atom feed
From: Oleg <oleg@okmij.org>
To: "caml-list@inria.fr" <caml-list@inria.fr>
Subject: [Caml-list] ANN: BER MetaOCaml N114, for OCaml 4.14.1
Date: Fri, 12 May 2023 15:04:53 +0100	[thread overview]
Message-ID: <ZF5Hhac7wysaZfZ8@Magus.localnet> (raw)


BER MetaOCaml N114 is a strict superset of OCaml 4.14.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 subset of the generated OCaml code can
also be converted to C, via offshoring. (The generated C needs no
particular runtime or GC.) 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).

The main changes in version N114 are
  -- smoothing the path for the possible future integration into OCaml;
  -- starting and almost finishing the complete solution to the
     long-standing CSP problem;
  -- complete support for offshoring

The problems of syntax are said to command the most discussion. This
message is no exception. In MetaOCaml, code to be generated is
enclosed in brackets: .<1 + 2>. (which may contain `holes', to be
filled with code: fun h -> .<1 + .~h>. where .~, analogous to
unquotation in Lisp, is called escape). Although `.<' and `.~' are not
valid in OCaml and hence can't be confused,
 `>.' is a a valid OCaml operator (and so are the operators that start
with that character sequence, like `>..' and `>.>.'). In fact, there
are some libraries that do define the operator `>.' and which
therefore cannot be used in MetaOCaml code. Version N114 introduces an
adaptive lexer, which treats `>.' identically to ordinary OCaml, until
it sees the first `.<'. If one arranges the code such that all
occurrences of the operator `>.' come before the opening bracket, one
can use the operator even in the same file as brackets. If one cannot
arrange code such way, or must use `>.' within brackets, one has to
use the alternative syntax for brackets and escapes:
        fun h -> [%metaocaml.bracket 1 >. [%metaocaml.escape h]]
although one may prefer
        fun h -> [%metaocaml.bracket 1 >. .~h]

For more explanations, please see
        https://okmij.org/ftp/ML/MetaOCaml.html
particularly about CSP, and
        https://okmij.org/ftp/meta-programming/tutorial/genc.html
about offshoring.
See also ChangeLog and NOTES.txt in the BER MetaOCaml distribution.

BER MetaOCaml N114 should be available through OPAM, hopefully soon.
In the meanwhile, it is available as a set of patches to the 
OCaml 4.14.1 distribution. 
        https://okmij.org/ftp/ML/ber-metaocaml.tar.gz
See the INSTALL document in that archive. You need the source
distribution of OCaml 4.14.1.


                 reply	other threads:[~2023-05-12 14:06 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:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

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

  git send-email \
    --in-reply-to=ZF5Hhac7wysaZfZ8@Magus.localnet \
    --to=oleg@okmij.org \
    --cc=caml-list@inria.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox