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=2.9 required=5.0 tests=DNS_FROM_RFC_ABUSE, DNS_FROM_RFC_POST,HTML_10_20,HTML_MESSAGE 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 B0EC1BC0A for ; Wed, 3 Jan 2007 02:59:34 +0100 (CET) Received: from web82112.mail.mud.yahoo.com (web82112.mail.mud.yahoo.com [209.191.84.225]) by concorde.inria.fr (8.13.6/8.13.6) with SMTP id l031xVGF004648 for ; Wed, 3 Jan 2007 02:59:34 +0100 Received: (qmail 65810 invoked by uid 60001); 3 Jan 2007 01:59:26 -0000 DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=sbcglobal.net; h=X-YMail-OSG:Received:Date:From:Subject:To:MIME-Version:Content-Type:Content-Transfer-Encoding:Message-ID; b=Z/oDsJgAnWcme8a1xlNLfGaCM5pIlDvjya879Pzsb3gM5Ck3MgbJ2RYf8wUbZFZtxs03cvXUxTJ5vfLEVH7RWnDhi+sTVfUlDUeI3tpQm4Ie+MfQjXMZvKUrSdi93pY+7Ecz5pZtvKp8dedm8F08ZLe1YgG3UU7DXatbJUe7uRs=; X-YMail-OSG: eEibACAVM1mbJMn.7ygkGJ8hAqVPAR_zjEK0mj_7R7uQL3obP210a2C5Yl6eY74TzMtDVM7HvasCwI6d1RnLsNW9CPUjA5z7M63VFn54wIJHRuWn4z6d1J_l3QGq1h7hJFGPcacWi00uwsk- Received: from [70.224.75.222] by web82112.mail.mud.yahoo.com via HTTP; Tue, 02 Jan 2007 17:59:26 PST Date: Tue, 2 Jan 2007 17:59:26 -0800 (PST) From: William W Smith Subject: symbol table containing symbol tables To: caml-list@yquem.inria.fr MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="0-1948611033-1167789566=:65043" Content-Transfer-Encoding: 8bit Message-ID: <886949.65043.qm@web82112.mail.mud.yahoo.com> X-Miltered: at concorde with ID 459B0E03.000 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; ocaml:01 symtable:01 symtable:01 recursive:01 syntax:01 ocaml:01 recursive:01 syntax:01 sbcglobal:98 int:01 int:01 data:02 data:02 declaration:02 declaration:02 --0-1948611033-1167789566=:65043 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit In pidgin OCaml I'd like to write something like type complicated = IVal of int | StrVa, of string | SymTableVal of symTable and symTable = Map(string -> complicated) I tried many variations on using the Map module to implement a recursive data structure like this. I failed miserably. (The above wasn't the syntax I ever used, but it gets the idea across.) However, when I create an object class [ 'key, 'content ] table : ('key -> 'key -> int) -> object ,,, end I can successfully declare type complicated = IVal of int | StrVal of string | SymTableVal of (string, complicated) table that does what I want. Ithis isn't the whole declaration of complicated, but I believe once I get this declaration working, the more quirky variations work too. Do I need one of the more advanced features of OCaml that I don't currently understand to use Map the way that I want without writing a whole table class? I don't even see how I can use Map from inside the table class to do what I want which would also be acceptable. I don't want to have to break open the Map module to modify it and thus change the licensing of my final program. Thanks Bill --0-1948611033-1167789566=:65043 Content-Type: text/html; charset=iso-8859-1 Content-Transfer-Encoding: 8bit In pidgin OCaml I'd like to write something like

type complicated =
    IVal of int
    | StrVa, of string
    | SymTableVal of symTable
and
    symTable = Map(string -> complicated)

I tried many variations on using the Map module to implement a recursive data structure like this.  I failed miserably.  (The above wasn't the syntax I ever used, but it gets the idea across.) 

However, when I create an object
class [ 'key, 'content ] table : ('key -> 'key -> int) ->
object
,,,
end

I can successfully declare
type complicated =
    IVal of int 
    | StrVal of string
    | SymTableVal of (string, complicated) table
that does what I want.   Ithis isn't the whole declaration of complicated, but I believe once I get this declaration working, the more quirky variations work too.

Do I need one of the more advanced features of OCaml that I don't currently understand to use Map the way that I want without writing a whole table class?  I don't even see how I can use Map from inside the table class to do what I want which would also be acceptable.

I don't want to have to break open the Map module to modify it and thus change the licensing of my final program.

Thanks

Bill
--0-1948611033-1167789566=:65043--