Path: news.daimi.aau.dk!grouleff From: Morten Grouleff Newsgroups: comp.lang.beta Subject: Re: Metaclasses in Beta Date: 15 Nov 1996 11:54:25 +0100 Organization: DAIMI, Computer Science Dept. of Aarhus Univ. Lines: 53 Sender: grouleff@aluminium.daimi.aau.dk Message-ID: References: <328C37F7.41C67EA6@cs.kuleuven.ac.be> NNTP-Posting-Host: aluminium.daimi.aau.dk Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit To: Walid Al-Ahmad X-Newsreader: Gnus v5.2.40/Emacs 19.30 Xref: news.daimi.aau.dk comp.lang.beta:10878 Walid Al-Ahmad writes: > > Beta considers patterns as objects in the sense that they are > first-class values (pattern variables). However, it seems that Beta does > not support the notion of metaclass as in Smalltalk. Some languages like > Java, C++, Eiffel do not treat classes as objects, but they do offer > facilities to define class data; i.e., data common to all objects of the > class (static members in C++, static variables and methods in Java, and > once routines in Eiffel). > My question is whether or not Beta offers some support to achieve the > same effect ? Please let me know where to find information in literature > on Beta regarding this topic. In C++, this really works as global variables with special names. To do the same thing in BETA, you could supply a level of block-structure: Here is a complete program, where all instances of the pattern A shares the integer x. ORIGIN '~beta/basiclib/v1.5/betaenv'; --- program:descriptor --- (# SharedForA: (# x: @Integer; (* Meant to be shared among instances of A *) A: (# y: @Integer; enter Y do this(SharedForA).x+y -> this(SharedForA).x exit this(SharedForA).x #) #); SA: @SharedForA; (* The single instance of the shared data *) a1,a2,a3: @SA.A; (* Create three instances of A *) do 10 -> a1 -> screen.putInt; screen.newLine; 15 -> a2 -> screen.putInt; screen.newLine; 7 -> a3 -> screen.putInt; screen.newLine; #) The 'this(SharedForA)' part is not necessary here, but in general it is good practice, as 'A' may inherit from something defining an 'x', which would then be the 'x' you would get. -- mailto:grouleff@daimi.aau.dk (Morten Grouleff)