From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@sympa.inria.fr Delivered-To: caml-list@sympa.inria.fr Received: from mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) by sympa.inria.fr (Postfix) with ESMTPS id CEA557EE6B for ; Wed, 27 Nov 2013 13:45:41 +0100 (CET) Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of omeragacan@gmail.com) identity=pra; client-ip=209.85.212.174; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="omeragacan@gmail.com"; x-sender="omeragacan@gmail.com"; x-conformance=sidf_compatible Received-SPF: Pass (mail2-smtp-roc.national.inria.fr: domain of omeragacan@gmail.com designates 209.85.212.174 as permitted sender) identity=mailfrom; client-ip=209.85.212.174; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="omeragacan@gmail.com"; x-sender="omeragacan@gmail.com"; x-conformance=sidf_compatible; x-record-type="v=spf1" Received-SPF: None (mail2-smtp-roc.national.inria.fr: no sender authenticity information available from domain of postmaster@mail-wi0-f174.google.com) identity=helo; client-ip=209.85.212.174; receiver=mail2-smtp-roc.national.inria.fr; envelope-from="omeragacan@gmail.com"; x-sender="postmaster@mail-wi0-f174.google.com"; x-conformance=sidf_compatible X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AlUBAFHolVLRVdSum2dsb2JhbABZgz9TqAeSaoEWCBYOAQEBAQEGCwsJFCiCJQEBBAEnGQEbEgYFAQMBCwYFCxohIgERAQUBChIZCAoIh1QBAwkGDaMqjFmDCYRFChknAwpkhygRAQUMjH+BRDMHhDMDmBSBMIstg0kYKYRXOg X-IPAS-Result: AlUBAFHolVLRVdSum2dsb2JhbABZgz9TqAeSaoEWCBYOAQEBAQEGCwsJFCiCJQEBBAEnGQEbEgYFAQMBCwYFCxohIgERAQUBChIZCAoIh1QBAwkGDaMqjFmDCYRFChknAwpkhygRAQUMjH+BRDMHhDMDmBSBMIstg0kYKYRXOg X-IronPort-AV: E=Sophos;i="4.93,782,1378850400"; d="scan'208";a="45705410" Received: from mail-wi0-f174.google.com ([209.85.212.174]) by mail2-smtp-roc.national.inria.fr with ESMTP/TLS/RC4-SHA; 27 Nov 2013 13:45:37 +0100 Received: by mail-wi0-f174.google.com with SMTP id ey16so1967700wid.1 for ; Wed, 27 Nov 2013 04:45:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:content-transfer-encoding; bh=nWMljRKvwr9r7lacKbjQwDn+reP7Av5mxXC71C64S7k=; b=vUBBwg7rPuQsf2A5NmyUlkSTDoDHH3uutwSOF7oJg4RMPbKiAwKI6WpDJB4DrAM7hO QsqoiTiQ9E6uqU82hNkFxe/SnppaZXdRzA8f5Lqsqbi/N6ZQb61BGr1lMRZ2MqgCaSTz CoU31/qgSlGxhHeoJw9HNFbCcfXzu2F9dDdb1XHdU/0zEEfzwK/xdTw0sGR0SHBMpiTx d/xCbp+a7ZerIULQayFsZOYjvPnFMrABxB4YHouVtHLJFs5yQPG+gZozuuwLCxWkgBeQ W39IN1Y+krANuZHkz4gQw+XcJ3FkLFbsvC8WmksfVRLPeMhgh66DacY74VOuD0oLSySC BrLg== MIME-Version: 1.0 X-Received: by 10.180.20.72 with SMTP id l8mr21612656wie.0.1385556337203; Wed, 27 Nov 2013 04:45:37 -0800 (PST) Received: by 10.217.78.131 with HTTP; Wed, 27 Nov 2013 04:45:37 -0800 (PST) In-Reply-To: <20131127073030.28963.qmail@www1.g3.pair.com> References: <20131127073030.28963.qmail@www1.g3.pair.com> Date: Wed, 27 Nov 2013 14:45:37 +0200 Message-ID: From: =?ISO-8859-9?Q?=D6mer_Sinan_A=F0acan?= To: oleg@okmij.org Cc: OCaml Mailing List Content-Type: text/plain; charset=ISO-8859-9 Content-Transfer-Encoding: quoted-printable Subject: Re: [Caml-list] ANN: improved BER MetaOCaml N101, for OCaml 4.01 Great news. Thanks. I'm wondering if new BER-MetaOCaml will be added to opam soon. --- =D6mer Sinan A=F0acan http://osa1.net 2013/11/27 : > > BER MetaOCaml N101 is now available. It is a strict superset of OCaml > 4.01, extending it with staging annotations to construct and run typed > code values. Besides being compatible with the current version of > OCaml, BER N101 has a number of improvements and significant changes > compared to BER N100. The new API for running code will hopefully > encourage the development of new ways to execute code values. > > The new BER N101 is not only source-compatible with OCaml 4.01 -- it > is also binary compatible. Any 4.01-built OCaml library and plugin > (including findlib) can be used with BER N101 in their binary form as > they are. The building of BER N101 no longer involves bootstrapping > and is hence much faster. > > > 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 =3D .<2 + 4>. > The type constructor 'code' takes as its argument the type of the > future-stage expression. Future-stage expressions are executed later, > but are type-checked now. Therefore, the generated code is assuredly > well-typed. Code fragments can be spliced into larger code contexts by > using the escape construct: > # let x =3D .< 2 + 4 >. in .< .~ x + .~ x >. ;; > - : int code =3D .<(2 + 4) + (2 + 4)>. > The run construct takes a code value, executes it and returns its result. > It is actually an ordinary function Runcode.run, which is also bound > to the prefix operation (!.). These operations are in the module > Runcode (which is not opened by default). For example: > # Runcode.run .< 2 + 3 >.;; > - : int =3D 5 > # open Runcode;; > # !. . x + y >. 2 3;; > - : int =3D 5 > The run construct only works on closed code values. Attempting to run > open code leads to an exception in the generator (which can be traced > as any other exception). > > > To the user, the two major differences of BER N101 from the previous > version are: > > -- the absence of environment classifiers (see below for more detail). > > -- The operation to run code is no longer a special form. It is an ord= inary > function [run : 'a code -> 'a] in the module Runcode. > For historical reasons, Runcode.run is also defined to be a prefix > operation (!.) (note the placement of the dot -- different from before= ). > > These two changes do require updating old MetaOCaml code. From experience, > the updates are very light: essentially put "open Runcode" > at the top of the file and globally replace all ".!" with "!.". > > The scope extrusion check first introduced in BER N100 made it > possible to remove environment classifiers while still preserving the > static guarantee: if the generator finishes successfully, the > generated code is well-typed and well-scoped. Environment classifiers > ensured well-scopedness when type-checking the generator -- but only > for pure generators. The scope extrusion check is executed when the > generator is run; however the check is comprehensive. Scope extrusion > is always caught, and caught early, whether the generator is effectful > or not. > > Another notable change is a new API for running code, with the special > type closed_code and the operations > val close_code : 'a code -> 'a closed_code > val open_code : 'a closed_code -> 'a code > The latter is total, the former does a scope extrusion check. > There may be many way to 'run' closed_code. Currently, MetaOCaml provides > val run_bytecode : 'a closed_code -> 'a > to run closed code by bytecode compiling it and then executing. More such > functions are possible. The function Runcode.run : 'a code -> 'a > and its alias, the prefix operation (!.), are the composition of > close_code and run_bytecode. > > BER N101 added a test for the well-formedness of recursive let: > .. and .. are now prohibi= ted. > They were allowed in all previous versions of MetaOCaml, which caused > a problem: a well-typed generator will produce well-typed code which > will nevertheless fail to compile. > > The new version builds code values faster, especially for functions > and nonbinding functions. The speed of the generation has not been a > problem. Now it got even faster. > > > BER MetaOCaml N101 is available: > > -- as a set of patches to the OCaml 4.01 distribution. > http://okmij.org/ftp/ML/ber-metaocaml-101.tar.gz > See the INSTALL document in that archive. You need the source > distribution of OCaml 4.01, see the following URL for details. > http://ocaml.org/install.html > > -- as a GIT bundle containing the changes relative to OCaml 4.01 > http://okmij.org/ftp/ML/metaocaml.bundle > First, you have to obtain the base > git clone https://github.com/ocaml/ocaml.git -b 4.01 ometa4 > and then apply the bundle. > > The older, N100 version, is available via OPAM. The new version will > come to OPAM, hopefully soon. > > For more explanation, please see > http://okmij.org/ftp/ML/MetaOCaml.html > as well as NOTES.txt in the BER MetaOCaml distribution. Hopefully the > release of BER MetaOCaml N101 would further stimulate using and > researching typed meta-programming. > > > -- > Caml-list mailing list. Subscription management and archives: > https://sympa.inria.fr/sympa/arc/caml-list > Beginner's list: http://groups.yahoo.com/group/ocaml_beginners > Bug reports: http://caml.inria.fr/bin/caml-bugs