Path: news.daimi.aau.dk!news.uni-c.dk!newsfeed.sunet.se!news01.sunet.se!sunic!mn6.swip.net!plug.news.pipex.net!pipex!tank.news.pipex.net!pipex!lade.news.pipex.net!pipex!news.be.innet.net!INbe.net!news.nl.innet.net!INnl.net!hunter.premier.net!news.mathworks.com!newsfeed.internetmci.com!in2.uu.net!EU.net!Germany.EU.net!Dortmund.Germany.EU.net!Informatik.Uni-Dortmund.DE!news From: knaut@schroeder (Claus-Peter Knaut) Newsgroups: comp.lang.beta Subject: Re: Global Variables Date: 07 May 1996 15:10:37 +0200 Organization: University of Dortmund, Germany Lines: 79 Sender: knaut@schroeder Message-ID: References: <318F2E76.41C6@idefix.physik.tu-berlin.de> Reply-To: Claus-Peter Knaut NNTP-Posting-Host: schroeder.informatik.uni-dortmund.de In-reply-to: Kai Petzke's message of Tue, 07 May 1996 13:05:26 +0200 X-Newsreader: Gnus v5.1 >>>>> ">" == Kai Petzke writes: In article <318F2E76.41C6@idefix.physik.tu-berlin.de> Kai Petzke writes: >> Claus-Peter Knaut wrote: >> >> Hello, >> >> We are developing an Probabilistik Database in BETA. We need >> global variables. How do you manage to use them. You can not >> place them in lib: attributes because there you can define no >> static objects. >> Yeah, this is something, that puzzles many newcomers to >> BETA. Why are there no easily useable global variables? >> Well, I believe, it is because the Mjolner people want you to >> write code with BETA, that can easily be re-used later in >> different types of applications. Maybe we did not explain the problem properly ! >> Think of your probabilistik database as a big machine. The >> first thing, that you want to do, is to define the machine >> itself, say in a file "prob.bet": >> (* probabilistik database *) ORIGIN >> '~beta/basiclib/v1.4/betaenv'; --- lib: attributes --- (* the >> main source file *) probDatabase: (# <> Attributes>>; >> (* private "global" data *) DatabaseGlobals: @<> DatabaseGlobals: Descriptor>>; InstanceGlobals: @<> InstanceGlobals: Descriptor>>; (* add more slots here, if >> required *) >> (* main methods *) init: (# <> >> #); query: (# querystring: ^text; result: ^text enter >> querystring <> exit result #); >> (* add more methods, if required *) #); We use the same method as in the code above ! We want to use the persistent store to save tuples of a relation on a disk. But to use a global variable in tuple, tuple.bet has to have its ORIGIN in a global database slot. To save the tuple, the pattern has to be declared in betaenv.bet, best in lib:attributes SLOT. But then i can not access the global variable, because i can not declare it in betaenv.bet. Hope that makes the point clear. I want to diskuss this further, because i don't see the right way. >> The result of that scheme is, that all methods of the >> probDatabase "machine" have access to those variables, that are >> "global" to the database, like those defined in DatabaseGlobals >> and InstanceGlobals. You can bind the DatabaseGlobals and >> InstanceGlobals patterns in some other files, say >> "database.bet" and "instance.bet". All of the modules of tha >> probabilisic database, that need the database globals should >> then INCLUDE the "database.bet" file, and all those, that need >> the instance globals should INCLUDE "instance.bet". >> Hope, that this is enough explanation. The advantage is, that >> in the end, all of your application is contained in a single >> BETA pattern. When you later include your appliation into some >> other BETA code, you have to include just one pattern, and need >> not care about name conflicts between global variables and >> other nice problems ... >> Kai