From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id LAA09541; Tue, 25 May 2004 11:54:32 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id LAA15441 for ; Tue, 25 May 2004 11:53:10 +0200 (MET DST) From: dido@imperium.ph Received: from gateway.imperium.ph ([202.175.240.154]) by concorde.inria.fr (8.12.10/8.12.10) with ESMTP id i4P9r7SH012318 for ; Tue, 25 May 2004 11:53:09 +0200 Received: from morgoth (morgoth.imperium.ph [192.168.1.35]) by gateway.imperium.ph (Postfix) with SMTP id A3690468E5 for ; Tue, 25 May 2004 17:56:14 +0800 (PHT) Received: by morgoth (sSMTP sendmail emulation); Tue, 25 May 2004 17:52:13 +0800 Date: Tue, 25 May 2004 17:52:13 +0800 To: caml-list@inria.fr Subject: [Caml-list] handling forward references in a compiler Message-ID: <20040525095213.GA2655@imperium.ph> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-Operating-System: Linux morgoth 2.6.5-gentoo-r1 User-Agent: Mutt/1.5.6i X-Miltered: at concorde with ID 40B31783.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Loop: caml-list@inria.fr X-Spam: no; 0.00; dido:01 undeclared:01 resorting:01 hash:01 hash:01 avoided:01 compiler:01 compiler:01 ocaml:01 referenced:02 referenced:02 imperative:04 imperative:04 wondering:04 processed:94 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk I'm writing a compiler for a language that allows undeclared forward references in OCaml, and I'm just wondering how one is supposed to handle these sorts of things without resorting to imperative features or multiple passes. Using imperative features, I'd be able to create a hash table of forward referenced symbols, containing lists of locations where these forward referenced symbols occur, and when the forward referenced symbol is finally declared, look for it in the hash table and resolve all the forward references there and then. But this requires that I put a temporary value in the intermediate representation that can be changed later. Another option is to make a second pass through the generated intermediate representation, and fixing up the forward references after all of the declarations have been processed, but this seems like a second traversal that can be avoided. Anyone have any better ideas? ------------------- To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ Beginner's list: http://groups.yahoo.com/group/ocaml_beginners