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 mail3-relais-sop.national.inria.fr (mail3-relais-sop.national.inria.fr [192.134.164.104]) by sympa.inria.fr (Postfix) with ESMTPS id 8618F800B6 for ; Sun, 1 Jan 2017 17:04:39 +0100 (CET) Authentication-Results: mail3-smtp-sop.national.inria.fr; spf=None smtp.pra=gabriel.scherer@gmail.com; spf=Pass smtp.mailfrom=gabriel.scherer@gmail.com; spf=None smtp.helo=postmaster@mail-qt0-f175.google.com Received-SPF: None (mail3-smtp-sop.national.inria.fr: no sender authenticity information available from domain of gabriel.scherer@gmail.com) identity=pra; client-ip=209.85.216.175; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="gabriel.scherer@gmail.com"; x-sender="gabriel.scherer@gmail.com"; x-conformance=sidf_compatible Received-SPF: Pass (mail3-smtp-sop.national.inria.fr: domain of gabriel.scherer@gmail.com designates 209.85.216.175 as permitted sender) identity=mailfrom; client-ip=209.85.216.175; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="gabriel.scherer@gmail.com"; x-sender="gabriel.scherer@gmail.com"; x-conformance=sidf_compatible; x-record-type="v=spf1" Received-SPF: None (mail3-smtp-sop.national.inria.fr: no sender authenticity information available from domain of postmaster@mail-qt0-f175.google.com) identity=helo; client-ip=209.85.216.175; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="gabriel.scherer@gmail.com"; x-sender="postmaster@mail-qt0-f175.google.com"; x-conformance=sidf_compatible IronPort-PHdr: =?us-ascii?q?9a23=3AQsHqzhabcRNHVnOuwHfQCj//LSx+4OfEezUN459i?= =?us-ascii?q?sYplN5qZr8W/bnLW6fgltlLVR4KTs6sC0LuK9fixEjVYvt6oizMrSNR0TRgLiM?= =?us-ascii?q?EbzUQLIfWuLgnFFsPsdDEwB89YVVVorDmROElRH9viNRWJ+iXhpTEdFQ/iOgVr?= =?us-ascii?q?O+/7BpDdj9it1+C15pbffxhEiCCzbL52Ixi6txndu80ZjYd/Nqo8yAbCr2dVde?= =?us-ascii?q?hR2W5mP0+YkQzm5se38p5j8iBQtOwk+sVdT6j0fLk2QKJBAjg+PG87+MPktR/Y?= =?us-ascii?q?TQuS/XQcSXkZkgBJAwfe8h73WIr6vzbguep83CmaOtD2TawxVD+/4apnVAPkhS?= =?us-ascii?q?EaPDE+7W/Xl9dwjLpFrx29uxxxzYnUYISPO/p/eKPWYNcWSGVFU8pUUSFKH4Gy?= =?us-ascii?q?YJYVD+cZP+lYoYnzqVUNoxWjGwejGPjiyiNUinLswaE2z/gtHAPA0Qc9H9wOqn?= =?us-ascii?q?PUrNDtOakTS++617PIzTTdYPNSxDzz9ZTHchA/rvGWQ71wa9faxE4gFwzflVqQ?= =?us-ascii?q?s43lMC2R1ugXqGiU8+pgWvy1i2E5sQF8uTevxsI2hYnIgoIZ0EzL9SJ8wIssI9?= =?us-ascii?q?CzVUB1YdmhEJRKtiGaMZN7QsIkQ2FyuSY10KcKuZChfCQSyJUo3R7fa/uAc4SS?= =?us-ascii?q?/h3jU+ORLS9/hHJmfbK/hhSy/VKnyu3mWcm51ktBoCldktTUqHwByxje5tKER/?= =?us-ascii?q?Z95EutxyuD2gHJ5u1ZI005lazWIIM7zLEqjJocq0HDEzf2mEroiK+WcV0p+u2y?= =?us-ascii?q?5OTmZrXqv4acN5Nohg3nPKQih86yDOQiPggBWGib/uu81Ln98kHjXLpKifg2nr?= =?us-ascii?q?HYsJDcO8sbura0DxFJ3osn8RqyDDer3M4GkXUaLV9JYg+LgorpNl3WJfD3F/a/?= =?us-ascii?q?g1CikDdxwPDGO6XsAprXIXfYirfhfKhy60pGxAoo0d9f54xbCqsfL/LpQULxu9?= =?us-ascii?q?nYAQU4Mwyw2eroFNJ91oYGVWKVHqCZKL/SsUOP5u83P+aDfooVuDLkJ/gh5v7u?= =?us-ascii?q?lmM5lEQGfaip2JsXcGq3Eu5nI0Wfe3rsg80OHX0EvgokH6TWjwilVTNcLyK1W6?= =?us-ascii?q?8zzjY4DYOkS4DZSdbpyLeI2SPzA4ZbfHsOXluFFHOtc4SfR98NbjiTK4lviGpX?= =?us-ascii?q?e6KmTtoO3Bu0tQL+g4FsLufO9zdQ4Z3q3sJ06umVjhoy+CZ5FeyS1miMSyd/mW?= =?us-ascii?q?ZeFGx+57x2vUEokgTL6qN/mfENSY1e?= X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: =?us-ascii?q?A0CFAABDKGlYf6/YVdFdGwEBAQMBAQEJA?= =?us-ascii?q?QEBFgEBAQMBAQEJAQEBgwwBAQEBAUA+gQwHohOCNIY3jjgqhXgCgVgHQxABAQE?= =?us-ascii?q?BAQEBAQEBARIBAQkLCwkbMoIzCoIsAQUjHQEbEgYGAwwGBQsNAgIJHQICIgERA?= =?us-ascii?q?QUBChIGARISiEIBAxgOols/jAKCAwUBHIMJBYNIChknAwpUgjUBAQEBBgEBAQE?= =?us-ascii?q?BARoCBhJ5hTqEYYJphGGCXQWHEQyIZYp7gXqEWopqgXVRhDeJWJB3FB6BFDaBK?= =?us-ascii?q?FESg0KCJyA0iQ8BAQE?= X-IPAS-Result: =?us-ascii?q?A0CFAABDKGlYf6/YVdFdGwEBAQMBAQEJAQEBFgEBAQMBAQE?= =?us-ascii?q?JAQEBgwwBAQEBAUA+gQwHohOCNIY3jjgqhXgCgVgHQxABAQEBAQEBAQEBARIBA?= =?us-ascii?q?QkLCwkbMoIzCoIsAQUjHQEbEgYGAwwGBQsNAgIJHQICIgERAQUBChIGARISiEI?= =?us-ascii?q?BAxgOols/jAKCAwUBHIMJBYNIChknAwpUgjUBAQEBBgEBAQEBARoCBhJ5hTqEY?= =?us-ascii?q?YJphGGCXQWHEQyIZYp7gXqEWopqgXVRhDeJWJB3FB6BFDaBKFESg0KCJyA0iQ8?= =?us-ascii?q?BAQE?= X-IronPort-AV: E=Sophos;i="5.33,432,1477954800"; d="scan'208";a="206618931" Received: from mail-qt0-f175.google.com ([209.85.216.175]) by mail3-smtp-sop.national.inria.fr with ESMTP/TLS/AES128-GCM-SHA256; 01 Jan 2017 17:04:38 +0100 Received: by mail-qt0-f175.google.com with SMTP id p16so424533139qta.0 for ; Sun, 01 Jan 2017 08:04:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to; bh=Bq2q3IBzHTscdYDfUrR/Faj7skiKgarTtSriBG02pkQ=; b=A/XfnKC3Ium3tc1UuyeIGFIxqXagmnhk4dhA/8G+dyq3SLyvAi1EVdXY/ZFCRv65fs MwklUeKj21uBYsuh6EA6G77gSNdqjZRBT4S2zLZGYwRzXw0blaUsF8vwau/OVjpjAinV KoXiZmX5tCq2igPliDFZu9qGRjj9yFRlPVZismssw5jJpaXuahclcVouRwjsDDaLaWPM +twSyrURXYir4MgXoZBzPyNEP5y+eiraroEhAnJ80dG9S7QbKg+uUuXtMSH4mHKEwa5a wdacBrN5fkZ9TUMfryuRIJ0hxrWATRRsTocDno/emIzvy6LIXzTMlyE74KvB1F5uJGu2 WehQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to; bh=Bq2q3IBzHTscdYDfUrR/Faj7skiKgarTtSriBG02pkQ=; b=B2DrTjmLhWuT3yoDIHckKN5EiQg0ZaSiiyjt8ISN7t8z5/xjepZR7jtBp267os76Kw T4drQZhjZ54mWN4h5tGew8rLolbKGL0zwNs4LM/5baeIGYPpVvIBhaIHtP7eggPnOAgz nteXom1yF4FEQo9aLHew+i+fW2V9YDYWUpFDTzj+JhRQklHhwgE/9vq35i3Nip26uu3Z VU1PX46jzJMuhXB8IxEC+aChqPXtnGL0g8oXqXYqIcQdQ3E9wZ72uiX8uGpCtQVVjs4n kmsJnB4FmKJN3yjswNRMzBQDzEXLwSBb5c05shqXdNQsEZg5jQqMuKOLJYYYkl1F9jn+ CiEA== X-Gm-Message-State: AIkVDXKR5BggXXOBSA7jjfY6B8EINfpsW0VldQJNsFOLN1OXe8U10om9RgxXJ5hrcUyuJyoLGO7Yan/6KZDaKw== X-Received: by 10.237.63.25 with SMTP id p25mr49492736qtf.18.1483286676797; Sun, 01 Jan 2017 08:04:36 -0800 (PST) MIME-Version: 1.0 Received: by 10.12.172.73 with HTTP; Sun, 1 Jan 2017 08:03:56 -0800 (PST) In-Reply-To: <20170101152022.GA1291@Magus.localnet> References: <20170101152022.GA1291@Magus.localnet> From: Gabriel Scherer Date: Sun, 1 Jan 2017 11:03:56 -0500 Message-ID: To: Oleg , caml users Content-Type: text/plain; charset=UTF-8 Subject: Re: [Caml-list] ANN: BER MetaOCaml N104, for OCaml 4.04.0 Congratulations on this interesting new release. Below are some minor remarks I had while looking at what you wrote on this release and its new features. One. I am not familiar with the MetaOCaml implementation but, intuitively, I wondered why attributes were used instead of extensions. In my book, (e [@attr]) is supposed to be an OCaml term that behaves as the expression (e), with some extra (tooling- or optimization- related) expression of intent. On the contrary, [%ext e] is allowed to have any semantics at all. One could even argue that it is semantically wrong to use attributes for MetaOCaml (as their forms do change the semantics), although that concern is alleviated by the use of the foreign-looking syntax .< ... >. which also indicates that something non-standard is going on. One interesting thing with the addition of the two new syntactic classes "pattern" and "value" is that, from a syntactic point of view, the idea of using extensions directly instead of home-grown syntax starts looking more reasonable: [%quote e], [%quote.pat e], [%quote.val e] (plus long forms metaocaml.quote*). Moving from .< e >. to [%quote e] is still arguably a bad deal for readability, but for the other two forms it would actually be an improvement over the current syntax. So I guess the benefit would depend a lot on how often these two new forms end up being used by MetaOCaml programmers. Using the extension syntax directly would certainly simplify a few things around MetaOCaml -- zero need for non-standard parsing, for example. Two. It is interesting that you mention that "function" allows to easily represent sets of clauses as expressions, as I was recently thinking about which kind of constructions would be made possible by taking "sets of clauses" as a first-class syntactic category. Three. I was professionally obligated to remark your formulation on where (genlet exp) actually places its definition: "The `let` is inserted right under the binder for the "latest" free variable contained in `exp`". This is exactly the style of placement used in sum-equivalence algorithms (and, I suppose, work on partial evaluation), typically the delimited-control-using presentation of "Extensional normalisation and type-directed partial evaluation for typed lambda calculus with sums" by Vincent Balat, Roberto Di Cosmo and Marcelo Fiore, 2004. Interestingly, these algorithms do not (only) place let-bindings in this way, but also case statements -- they want the case-distinction on the bound value to have as large a scope as possible. This suggests that maybe the "finding the earliest place to introduce an expression" is a really useful primitive to have for metaprogramming, and that your "genlet" could be reconstructed from it, but right now I don't see how to expose it without letting the user do delimited control -- which is what you started from. On Sun, Jan 1, 2017 at 10:20 AM, Oleg wrote: > > BER MetaOCaml N104 is a strict superset of OCaml 4.04.0 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 N104 comes with one minor and two notable improvements. > The minor improvement is the availability of the native MetaOCaml. If > the generator is compiled in native mode (using metaocamlopt), the > dynamically generated and run code will be natively-compiled as > well. The lack of native mode was the most frequently heard criticism > of MetaOCaml, although in my experience it hardly even > matters. Off-line code specialization seems to be far more prevalent > and useful than online one. Anyway, here we have it. > > The notable new features -- not seen in MetaOCaml (or MetaML, for that > matter) -- are generating pattern-matching expression with the > statically unknown number of clauses, and let-insertion as a > primitive. To wit, |genlet exp| inserts |let freshname = exp in ...| > somewhere in the generated code and returns |..| (unless |exp| > is already syntactically a value such as a variable reference). > The let-statement is inserted at the most appropriate place. > > BER MetaOCaml N104 should be available though OPAM, hopefully soon. > In the meanwhile, it is available as a set of patches to the > OCaml 4.04.0 distribution. > http://okmij.org/ftp/ML/ber-metaocaml-104.tar.gz > See the INSTALL document in that archive. You need the source > distribution of OCaml 4.04.0, see the following URL for details. > > For more explanations, please see > http://okmij.org/ftp/ML/MetaOCaml.html > as well as ChangeLog and NOTES.txt in the BER MetaOCaml distribution. > > > -- > 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