From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=disabled version=3.1.3 Received: from mail4-relais-sop.national.inria.fr (mail4-relais-sop.national.inria.fr [192.134.164.105]) by yquem.inria.fr (Postfix) with ESMTP id A708CBBAF for ; Sat, 4 Oct 2008 02:59:47 +0200 (CEST) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AosBACtd5khKfU4YlGdsb2JhbACBcU2QZT4BAQEBCQkMBxEDoEqGdQEC X-IronPort-AV: E=Sophos;i="4.33,359,1220220000"; d="scan'208";a="29888074" Received: from ey-out-2122.google.com ([74.125.78.24]) by mail4-smtp-sop.national.inria.fr with ESMTP; 04 Oct 2008 02:59:06 +0200 Received: by ey-out-2122.google.com with SMTP id 6so592617eyi.15 for ; Fri, 03 Oct 2008 17:59:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=gamma; h=domainkey-signature:received:received:organization:to:subject:date :user-agent:references:in-reply-to:mime-version:content-type :content-transfer-encoding:content-disposition:message-id:from; bh=623thMamghgill0MjJb+Xu5CQRcluoUoYvd3QjYvlIQ=; b=Vb8JZTfI+sTCmFQQ6JHSb/oZXtbCHqi4jFqrDLoXh0SoBNgJc2PLzgDSE8IzGX7OQ9 FItXNdkgQX1PjLI3CcSAccdZwjNVAV1CX181ojsMZerJHBs1GU9n4KkcL7oVjwXyXy4S UkM32SzOCBzH9XXOF0clr1TtOtQpChpb+zx84= DomainKey-Signature: a=rsa-sha1; c=nofws; d=googlemail.com; s=gamma; h=organization:to:subject:date:user-agent:references:in-reply-to :mime-version:content-type:content-transfer-encoding :content-disposition:message-id:from; b=tpiLs4y30AA5L2JUgSMFxKebkcVecxOZPbqzbPCYVnPg1Clh7rsHm2X4BzumtHiVrJ 6zzyPKPFSLxG/c7A+SzD6FLtLnxsdYN828fcguau/5eGgdq8e9qs12+hZqgAcaYCUJ4u AHiBfXThaEJI5Zxvy1DX3RFB1jMRoUXQT36W0= Received: by 10.210.60.8 with SMTP id i8mr2124043eba.183.1223081946322; Fri, 03 Oct 2008 17:59:06 -0700 (PDT) Received: from leper.local (host86-139-250-145.range86-139.btcentralplus.com [86.139.250.145]) by mx.google.com with ESMTPS id q9sm6918865gve.5.2008.10.03.17.59.05 (version=TLSv1/SSLv3 cipher=RC4-MD5); Fri, 03 Oct 2008 17:59:05 -0700 (PDT) Organization: Flying Frog Consultancy Ltd. To: caml-list@yquem.inria.fr Subject: Re: [Caml-list] Metaprogramming features Date: Sat, 4 Oct 2008 03:00:02 +0100 User-Agent: KMail/1.9.9 References: <884069.59268.qm@web54601.mail.re2.yahoo.com> In-Reply-To: <884069.59268.qm@web54601.mail.re2.yahoo.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200810040300.02624.jon@ffconsultancy.com> From: Jon Harrop X-Spam: no; 0.00; metaocaml:01 ocaml:01 metaocaml:01 ocaml:01 vastly:01 low-level:01 parsers:01 bytecodes:01 non-trivial:01 compiler:01 ocaml's:01 compiler:01 run-time:01 frog:98 char:01 On Friday 03 October 2008 16:09:40 Dario Teixeira wrote: > Hi, > > > I really wish that the basic features of metaocaml, namely > > .< >., .~ and .! were included in OCaml proper. The many other > > experimental features of metaocaml could stay 'experimental', > > those are the 3 which are sorely needed. > > To those of us not familiar with MetaOcaml, could you give us > an overview of what these features mean and why they are so > special? MetaOCaml extends OCaml with three constructs that allow programs to generate, compile and evaluate code at run time. Code is represented by the form: .< 1 + 2 >. This may be executed using: .! .< 1 + 2 >. Values may be injected into code using: .< 1 + .~x >. This makes it vastly easier to turn term-level interpreters into compilers to obtain substantial performance improvements. However, MetaOCaml has problems: 1. Obvious applications are low-level compilers for regular expressions, parsers and bytecodes but MetaOCaml imposes the limitations of OCaml (e.g. slow char and int handling) which makes it unsuitable for most such applications. 2. Non-trivial features in the target language can require great complexity, e.g. writing a compiler in MetaOCaml for a language with exceptions imposes CPS everywhere which is obfuscated and slow without language support. 3. You cannot generate new pattern matches to leverage OCaml's optimizing pattern match compiler in your run-time generated code (but you can use static ones). -- Dr Jon Harrop, Flying Frog Consultancy Ltd. http://www.ffconsultancy.com/?e