Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!wuarchive!gem.mps.ohio-state.edu!apple!agate!shelby!portia!sreerang From: sreerang@portia.Stanford.EDU (Sreeranga Rajan) Newsgroups: comp.lang.prolog Subject: Re: hierarchy among modules in prolog Keywords: modules, hierarchy, Quintus prolog Message-ID: <5669@portia.Stanford.EDU> Date: 8 Oct 89 20:28:53 GMT References: <5641@portia.Stanford.EDU> <2326@munnari.oz.au> Sender: Sreeranga Rajan Reply-To: sreerang@Portia.Stanford.EDU (Sreeranga Rajan) Organization: Stanford University Lines: 32 In article <2326@munnari.oz.au> ok@cs.mu.oz.au (Richard O'Keefe) writes: >In article <5641@portia.Stanford.EDU>, sreerang@portia.Stanford.EDU (Sreeranga Rajan) writes: >> I would like to know if it is possible to make the visibility of >> assertions in modules hierarchical in Prolog. > >Please say more. What is it that you want to do? >There are two separate questions: the structure of the space of module >names, and the set of visibility graphs you can construct. > > > >Now it really doesn't take a lot of ingenuity to write a little >preprocessor that will generate these headers automatically. In fact, >the headers and the clauses don't have to be in the same files. >"Hierarchical" could mean almost anything, so there's a good chance that >the sketch above doesn't address your problem. Tell us more about what >you're trying to do. In trying to write a small compiler for a Algol-like language I need to having scoping of declarations and the visibility rules as in Algol-like languages.The most common occurrence would be a loop variable. Such a variable most of the time would be the same identifier in a main program and subprograms. In such a case I would like to create modules dynamically in prolog and have exactly the same scoping and visibility among modules arranged hierarchically. The solution given by Richard O'Keefe does give a solution, but falls short of solving the problem of having only private predicates in the case of dynamycally created modules. To clarify further, if I have a main program with subprograms and functions, I would like to create modules dynamycally corresponding to each of them so that I can have private name spaces for each, and also address the problem of scope and visibility hierarchically.