Path: news.daimi.aau.dk!news.uni-c.dk!newsfeed.sunet.se!news01.sunet.se!sunic!uunet!in2.uu.net!news.mathworks.com!zombie.ncsc.mil!nntp.coast.net!fu-berlin.de!zrz.TU-Berlin.DE!news From: Kai Petzke Newsgroups: comp.lang.beta Subject: Re: Global Variables Date: Tue, 07 May 1996 13:05:26 +0200 Organization: Technical University Berlin, Germany Lines: 66 Message-ID: <318F2E76.41C6@idefix.physik.tu-berlin.de> References: NNTP-Posting-Host: foxylady.physik.tu-berlin.de Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Mailer: Mozilla 2.0 (X11; I; IRIX 5.2 IP20) To: Claus-Peter Knaut 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. 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: (# <>; (* private "global" data *) DatabaseGlobals: @<>; InstanceGlobals: @<>; (* add more slots here, if required *) (* main methods *) init: (# <> #); query: (# querystring: ^text; result: ^text enter querystring <> exit result #); (* add more methods, if required *) #); 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