English version
Accueil     À propos     Téléchargement     Ressources     Contactez-nous    

Ce site est rarement mis à jour. Pour les informations les plus récentes, rendez-vous sur le nouveau site OCaml à l'adresse ocaml.org.

Browse thread
symbol table containing symbol tables
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2007-01-03 (01:59)
From: William W Smith <sesquized@s...>
Subject: symbol table containing symbol tables
In pidgin OCaml I'd like to write something like

type complicated =
    IVal of int
    | StrVa, of string
    | SymTableVal of symTable
    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) -> 

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.