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=1.8 required=5.0 tests=AWL,DNS_FROM_RFC_POST, SPF_NEUTRAL autolearn=disabled version=3.1.3 Received: from mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) by yquem.inria.fr (Postfix) with ESMTP id CF1F0BBC4 for ; Fri, 17 Apr 2009 19:25:38 +0200 (CEST) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AksDAIdY6EnRVdykimdsb2JhbACVej8BAQEKCQwHDwWoJIEJj3sBAwEDg3oG X-IronPort-AV: E=Sophos;i="4.40,205,1238968800"; d="scan'208";a="24761477" Received: from mail-fx0-f164.google.com ([209.85.220.164]) by mail2-smtp-roc.national.inria.fr with ESMTP; 17 Apr 2009 19:25:38 +0200 Received: by fxm8 with SMTP id 8so1150503fxm.27 for ; Fri, 17 Apr 2009 10:25:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:from:to :content-type:content-transfer-encoding:mime-version:subject:date :x-mailer; bh=PEuztgS+DFbuhctTFtXZtfvOjbjtLPs3rgnkl5n46Bc=; b=WShdpZj2y4hyCxdmWhmL/WYhCS7OCw3GgUzgZocfrL+b091lNaMPCIPxq59x5OKBTj xP06m3KTqJOnEGlJv7WrccUZzqa6x7zmQlaNqcXZ/LDOk55vlIXom5xx8yUd5wXXWrIT 2prNKOnNoT+hDnXMctFfN7oYGJ7lddDSphKHY= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:from:to:content-type:content-transfer-encoding :mime-version:subject:date:x-mailer; b=n3BzjxZyhVtBozha8zbY4lCCDoSB7WMCdAJA8/JFDH6vDkKGTEu8Goyp9R3AEFkFhz GmZtKiHKjWiVNCtFu+P6J7CCeUyTIsKYSoROSGyTwbnBwvWOQp2LggVFi3HacO4FWm9y xX/D2IdPkzBQtqziW+TcaxkMvAHgOvP/ia5Go= Received: by 10.86.90.2 with SMTP id n2mr2200187fgb.39.1239989138115; Fri, 17 Apr 2009 10:25:38 -0700 (PDT) Received: from ?10.10.30.15? (228.Red-83-33-96.dynamicIP.rima-tde.net [83.33.96.228]) by mx.google.com with ESMTPS id 4sm1247350fgg.15.2009.04.17.10.25.37 (version=TLSv1/SSLv3 cipher=RC4-MD5); Fri, 17 Apr 2009 10:25:37 -0700 (PDT) Message-Id: <06125B5C-F0A1-465E-967E-03B125947F4B@gmail.com> From: Joel Reymont To: O'Caml Mailing List Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes Content-Transfer-Encoding: 7bit Mime-Version: 1.0 (Apple Message framework v930.3) Subject: quasiquoting and pattern matches Date: Fri, 17 Apr 2009 18:25:35 +0100 X-Mailer: Apple Mail (2.930.3) X-Spam: no; 0.00; haskell:01 lbl:01 lbl:01 ocaml:01 expr:01 expr:01 lprim:01 mainland:98 compile:01 compile:01 ident:01 ast:02 hacker:02 match:02 match:02 There's an example in the Geoffrey Mainland's Haskell quasiquotation paper [1] that looks like this: peep :: [ Asm ] -> [ Asm ] peep [:asm| mov&s $&r1, &r2 cmp $&r3, &r4 je &lbl |] : rest | r3 = r1 ^ r4 = r2 = [:asm| mov&s $&r1, &r2 jmp &lbl |] : rest ... Is it possible to do the same in OCaml, i.e. use antiquotations in pattern matches? I have not seen it done this way before, all the examples match the AST, e.g. from jsgen.ml let compile_implementation modulename expr = let ce = match expr with | Lprim (Psetglobal id, [e]) -> enter_setglobal id; <:stmt< var $id:jsident_of_ident id$ = $comp_expr false e$; >> | _ -> unimplemented "compile_implementation" expr in let ret = (ce, !reloc_info) in reloc_info := []; ret Thanks, Joel [1] http://www.eecs.harvard.edu/~mainland/ghc-quasiquoting/ --- Mac hacker with a performance bent http://linkedin.com/in/joelreymont