Path: news.daimi.aau.dk!news.daimi.aau.dk!eernst From: eernst@quercus.daimi.aau.dk (Erik Ernst) Newsgroups: comp.lang.beta Subject: Immediate constructs (Was: Re: Recursive, double INNER) Date: 15 Feb 1995 19:24:27 GMT Organization: DAIMI, Computer Science Dept. of Aarhus Univ. Lines: 131 Message-ID: References: <3hdl0d$c2l@belfort.daimi.aau.dk> NNTP-Posting-Host: quercus.daimi.aau.dk In-reply-to: alfh@byleist.ifi.uio.no's message of 10 Feb 1995 14:33:20 GMT In article alfh@byleist.ifi.uio.no (Alf-Ivar Holm) writes: In article <3hdl0d$c2l@belfort.daimi.aau.dk> jco@daimi.aau.dk (Jens Cornelius Olsen) writes: [snip] > it was (or is) considered to include > a shorter version of the two statements involving callMe in the syntax: > > &(this(forAllThings)##) > > but for now we are forced to use the callMe variable. Although the (this(patternName)##) statement would be shorter, I guess the use would be limited to object creation. (No computed references and the like.) It would be very nice to have &(this(patternName)##) and also patternName(# ... #)##. They are both examples of immediate, anonymous constructs, i.e. constructs that introduce and use program entities which are normally explicitly declared and named. An example of this which has been around for many years is the (lambda ...) construct in lisp et al. In BETA a prominent example is 'patternName(# ... #)' as an imperative. An immediate, anonymous construct is relevant whenever the given program entity will only be used at one point in the program. When the name is only used once, it just pollutes the name space of the program and makes it harder to read and more tedious to write. Here's a nice, contrived example using 'patternName(# ... #)##': Suppose a chemicalPlant forks off threads to control aspects of chemical processes, like &|system(# stabilize: ^stabilizer; do &pressure_stabilizer[]->stabilize[]; 35.0->stabilize.best_value; cycle(# do get_pressure->stabilize->set_pressure; 1->sleep #) #)[] -> fork; where stabilizer: realObject(# best_value: @real do INNER #); and "get_pressure" reads some kind of meter and "set_pressure" interfaces to some external pressure control device. Then we might want to adjust the strategy used by pressure_stabilizer now and then, like stabilizer (# do (if true // value>1.2*best_value then high_alert; best_value*value->sqrt->value; // value<0.8*best_value then low_alert; best_value*value->sqrt->value; else no_alert; (value+best_value)/2.0->value; if); #)## -> chemicalPlant.pressure_stabilizer##; This specialization of stabilizer is only used at this point of the code, and the chemicalPlant wants to make instances of pressure_stabilizers. So we want a pattern variable, and we want it from an immediate (anonymous) construct. It's very much like another immediate, anonymous construct, do ... chemicalPlantPattern (# pressure_stabilizer::< (# do (if true // value>1.2*best_value then high_alert; best_value*value->sqrt->value; // value<0.8*best_value then low_alert; best_value*value->sqrt->value; else no_alert; (value+best_value)/2.0->value; if); #); #); ... except that we _cannot_ afford the luxury of creating a _new_ chemicalPlant but need instead to adjust the behaviour of an already existing one. In my experience situations like this one are not all that rare, and I think the ability of BETA to support anonymous constructs (other than this one, as yet) is very important. Without that, the source code would be a lot less readable (and also much more tedious to write). Actually I don't understand that the importance of immediate constructs seems to be an absolute non-issue in most news groups discussing programming languages! A typical BETA program probably contains a substantially larger number of classes/patterns than a program of comparable complexity in, say, Eiffel, Sather, or C++. It is simply a lot easier to create patterns/classes when immediate constructs are allowed, and the many little enhancements or "customizations" of already established functionality is clearly one of the forms that widespread reuse can take. Does anybody see any serious problem (other than the grammar :-) in allowing the construct ## as a ? sin-comments-looked-cere-forward-to-ly yours, -- Erik Ernst eernst@daimi.aau.dk Computer Science Department of Aarhus University, Denmark