Path: news.daimi.aau.dk!datpete From: datpete-nospam@daimi.aau.dk (Peter Andersen) Newsgroups: comp.lang.beta Subject: Re: BETA and X-Windows (was: Re: LISP and X-Windows) Date: 27 Sep 1994 09:54:39 GMT Organization: DAIMI, Computer Science Dept. at Aarhus University Lines: 76 Message-ID: <368q4v$as6@belfort.daimi.aau.dk> References: <35bn78$ms@belfort.daimi.aau.dk> <362dfc$84v@network.ucsd.edu> NNTP-Posting-Host: angers.daimi.aau.dk Thus spake mbk@inls1.ucsd.edu (Matt Kennel): >Jacob Seligmann (jacobse@daimi.aau.dk) wrote: >: Peter da Silva wrote: >: > Jacob Seligmann wrote: >: > >: > > AwEnv(# do (&label(# init:: (# do 'Hello world' -> label #) #)[]).init #) >: > >: > Why do all these new languages people come up with always end up looking >: > like someone decided Lisp was too readable and added a handful of TECO and >: > a splash of Forth to the mix? >: Admitted, you probably do need a firm grasp of BETA to appreciate the >: above concoction of just about every single syntactic construction >: available in the language (inheritance, anonymous pattern, virtual >: binding, assignment, instantiation, dereferencing, computed remote, >: etc.) into a single expression! >: It's a complex combination, and it's complex to read (especially when >: written as a one-liner, and even more so if you're unfamiliar with the >: terse syntax), but I still believe it is an excellent demonstration of >: BETA's orthogonality. >Orthogonal to my brain, certainly. ;-) >I'm a newbie---could you "deconstruct" this one-liner? Let me try to explain it: 1) This version of the program is probably the easiest to grasp for new-comers: AwEnv (# l: @Label; do l.init; 'Hello world' -> l.label; #) which means, that you execute an instance of the Athena Widget environment AwEnv, which is specialized to contain a static (@) instance of the pattern ("class") called Label. The action part (do-part) of AwEnv is extended with two statements: The first one invokes the initialization attribute of the Label object, and the second one assigns a text constant to the label atribute of the Label (which sets the text in the Label). 2) Now, the init attribute of a Label is actually a virtual pattern. That is, it can be further bound or final bound in specializations of Label. By final binding it to do the initialization of the label attribute, the program becomes: AwEnv (# l: @Label(# init:: (# do 'Hello world' -> l.label; #)#); do l.init; #) 3) Finally, there is no actual need to access attributes in the Label object called l, except for the init pattern. This means that we can use two other constructs in the BETA language to obtain the program, Jacob wrote: a) The construct &P means "dynamically instantiate a P object", and thus the construct &P[] exits a reference to a dynamically created P object. b) The construct (ev).p means "perform the evaluation ev - which must be an evaluation, that exits a reference, which has a qualifying pattern, that has an attribute called p (this is checked at compile time) - and invoke the p attribute of it. Using these two constructs, you end up with the one-liner Jacob wrote. I hope this has clarified the program a little. Sincerely, Peter Andersen, Mjolner Informatics