caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: oleg@okmij.org
To: caml-list@inria.fr
Subject: [Caml-list] ANN: simplified BER MetaOCaml N102, for OCaml 4.02.1
Date: Fri,  9 Jan 2015 00:34:30 -0500 (EST)	[thread overview]
Message-ID: <20150109053430.937C8C382B@www1.g3.pair.com> (raw)


BER MetaOCaml is a strict superset of OCaml, adding operations to
construct and run typed code values. BER MetaOCaml N102 is the new
version, which is source _and_ binary compatible with OCaml
4.02.1. That is, 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.

On the surface, BER N102 has hardly changed from the earlier BER N101.
All BER N101 code should work with the new version as it was. The
users may however notice better printing: of code, error messages and
cross-stage-persistent values. The implementation however has changed
quite a bit, extensively relying on attributes and bringing MetaOCaml
very close to OCaml. It is now a distinct possibility that -- with
small hooks that may be provided in the future OCaml versions --
MetaOCaml becomes just a regular library or a plug-in, rather being a
fork. (Please see below for details.)

The staging annotations are: 
    bracket: .< e >.  to delay computation (to the future stage)
    escape:  .~ e     to perform a computation e and splice-in the result
    run:     !. e     to run a future-stage computation, or code, now

A special type constructor, called 'code' builds the type of
future-stage computations, or code expressions:
    # .< 2 + 4 >.;;
    - : int code = .<2 + 4>. 
For more details, 
        http://okmij.org/ftp/ML/MetaOCaml.html#using


BER MetaOCaml N102 is available:

-- as a set of patches to the OCaml 4.02.1 distribution. 
        http://okmij.org/ftp/ML/ber-metaocaml-102.tar.gz
See the INSTALL document in that archive. You need the source
distribution of OCaml 4.02.1, see the following URL for details.
        http://ocaml.org/install.html

-- as a GIT bundle containing the changes relative to OCaml 4.02.1
        http://okmij.org/ftp/ML/metaocaml.bundle
First, you have to obtain the base
       git clone https://github.com/ocaml/ocaml.git -b 4.02.1 ometa4
and then apply the bundle.

The older, N101 version, is available via OPAM. The new version will
come to OPAM, hopefully soon.

Although on the surface BER N102 is almost the same as the earlier
version, internally it is quite different. To give the idea of the
difference, it is instructive to compare the amount of changes BER
MetaOCaml makes to the OCaml distribution. The old BER N102 modified
32 OCaml files. The new BER N102 modifies only 7 (that number could be
further reduced to only 2; the only file with nontrivial modifications
is typecore.ml). The patch size was 49729 bytes before and 34066 bytes
now.

The principal change is the extensive use of attributes, the new
feature of OCaml 4.02. Staging annotations -- brackets, escapes and
CSP -- are now really annotations: attributes on the Parsetree and
Typedtree. MetaOCaml also uses a Typedtree attribute to mark
non-expansive nodes (the non-expansiveness check is performed before
the bracket-translation but is used only after). An attribute on
value_description tells the staging level of the value.

There is no longer a separate Typedtree traversal pass, after the type
checking, to translate brackets and escapes. That means that for
staging-annotation-free code, MetaOCaml has no substantial overhead.
BER N102 has started on revamping cross-stage-persistence; quite a few
CSP have become printable and, mainly, serializable. Non-serializable
CSP were the only impediment to native MetaOCaml.

For more explanations, please see
        http://okmij.org/ftp/ML/MetaOCaml.html
as well as ChangeLog and NOTES.txt in the BER MetaOCaml distribution.

Hopefully the release of BER MetaOCaml N102 would further stimulate
using and researching typed meta-programming -- and perhaps merging
of MetaOCaml into the mainstream OCaml.



             reply	other threads:[~2015-01-09  5:34 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-01-09  5:34 oleg [this message]
2015-01-10 17:55 ` Jeremy Yallop

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=20150109053430.937C8C382B@www1.g3.pair.com \
    --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;
as well as URLs for NNTP newsgroup(s).