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.0 required=5.0 tests=AWL,SPF_NEUTRAL autolearn=disabled version=3.1.3 Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by yquem.inria.fr (Postfix) with ESMTP id 9EE77BC0A for ; Thu, 24 May 2007 16:23:30 +0200 (CEST) Received: from an-out-0708.google.com (an-out-0708.google.com [209.85.132.248]) by concorde.inria.fr (8.13.6/8.13.6) with ESMTP id l4OENSUo012650 for ; Thu, 24 May 2007 16:23:29 +0200 Received: by an-out-0708.google.com with SMTP id b15so53580ana for ; Thu, 24 May 2007 07:23:28 -0700 (PDT) DKIM-Signature: a=rsa-sha1; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:message-id:date:from:sender:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references:x-google-sender-auth; b=EXTL7wmrFTUaVNHN43O0BqbuhiuzSL94Ir2FLHFMx/UFlbh/s2QBXgYZWSnvq1/v3dWv9l7gseBk6CQZIaQu5lS6zOL8LYZSMT3poSk0lOxofEH/WqBAs2BqktM2X9u2ffZMDSJBGpVmwTSO/8if3t5QR/2KHExN2W9Qxsn/mAs= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:sender:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references:x-google-sender-auth; b=Ed8d61UHuLbx/UX3Lovj2A8R5zltm2kTuozTAp7To7gTbSujVFUvW735ZpjPbGukzowcRmn0lirMeGVQNSkBbquSLJGoqz96AxwKYzFyM6TOHrD5Crx3F8/aOBdplfoU2VWcARc/+cMURR2tR4InRQ6mmb11KVcxp0hTKtnAuZQ= Received: by 10.114.94.1 with SMTP id r1mr913042wab.1180016607914; Thu, 24 May 2007 07:23:27 -0700 (PDT) Received: by 10.114.131.4 with HTTP; Thu, 24 May 2007 07:23:27 -0700 (PDT) Message-ID: <604682010705240723v609af56eq13380ced449565c@mail.gmail.com> Date: Thu, 24 May 2007 10:23:27 -0400 From: "Stephen Weeks" Sender: stephentweeks@gmail.com To: "Niko Matsakis" Subject: Re: [Caml-list] Extracting common information Cc: caml-list@yquem.inria.fr In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline References: X-Google-Sender-Auth: bf6f641bcc688de7 X-Miltered: at concorde with ID 46559FE0.002 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; compiler:01 ocaml:01 annotation:01 annotations:01 compiler:01 node:01 dynamically:01 extensible:01 typing:01 caml-list:01 variant:02 ast:02 tree:02 types:03 static:03 > I am working on a simple compiler in Ocaml, and having some difficulty > settling on the best design for my AST. ... > then I realized I would want to thread along some annotation to store the > types, line numbers, and things like that. Since these annotations will > change between compiler passes, I ran in to the same design problem when writing MLton. My solution was to use lisp-style property lists, but with appropriate ML static typing. See http://mlton.org/PropertyList The essence of the solution is to use a dynamically extensible sum type. Each tree node holds a list ref of values in the sum type. Each compiler pass builds a new variant of the sum type and stores whatever it needs in the list.