Path: news.daimi.aau.dk!sbrandt From: sbrandt@daimi.aau.dk (S|ren Brandt) Newsgroups: comp.lang.beta Subject: Re: Something like computed names in BETA ? Date: 14 Nov 1994 11:18:52 GMT Organization: DAIMI, Computer Science Dept. at Aarhus University Lines: 90 Message-ID: <3a7h2s$elc@belfort.daimi.aau.dk> References: <39tqrf$q5m@poseidon.uni-paderborn.de> NNTP-Posting-Host: chrysler.daimi.aau.dk >> "A computed reference may be used in a computed remote name, >> which has the form: >> >> (ComputedReference).name >> >> [...]" >> >> Can you do something like this in BETA: >> >> Reference.(ComputedName) >> >> I don't think it works this way, but you might get the >> idea want I want ! As Erik mentions, the only BETA construct coming somewhere near what you want, is the pattern variable construct. Pattern variables may be thought of as a way to turn BETA patterns into first-class language citizens, i.e. allowing them to be passed around as parameters and computed at runtime. What you seem to request, is a corresponding language construct or library turning pattern *attributes* into first class values. This is not currently possible in BETA. General "meta object protocols" are part of certain dynamically typed languages such as SELF ("Mirrors") and CLOS (the "MOP"). Using any of these, you may simulate BETA pattern variables and computed names or express most other meta object stuff you may need. However, CLOS and SELF are *dynamically typed* languages based on a dynamic development environment. This development environment eases the implementation of meta object protocols since compile time information is still directly accessible to the running program. >A work-around which may be applicable: use pattern variables. The >computation would perhaps look like "obj.ComputePtn->pv##", binding >"pv" to some pattern enclosed in the pattern of which "obj" is an >instance. But the type of "pv" might be a problem: it can't express >more than what is known about all possible outcomes of >"obj.ComputePtn", and that might not be enough to make the pattern >really useful. >"Reference.(ComputedName)" would be a very nice possibility. It would >be quite different from "(ComputedReference).name", though, as there >would not be a simple re-writing scheme into "BETA-without-it", like > (ReferenceExpression).name; > ---> > (# temp: ^appropriatePattern; > do ReferenceExpression -> temp[]; > temp.name; > #); >To obtain the value corresponding to "reference-to-name" you would >have to introduce something which has been proposed under the name >"attribute variables". There should also be some mechanism for >traversing all possible values for such an attribute variable, given a >suitable context. (Such as "scan all patterns immediately enclosed by >the pattern given by this pattern variable"). And, to keep BETA >statically typed, you would need some way to obtain and exploit type >information regarding those patterns. The language BETA >doesn't have it (for now), and I don't expect anything like that to >become part of the Mjolner BETA System (MBS) anytime soon. >> Another question is: Can I determine at runtime which >> methods an object understands ? >Again, an answer to such a question would have to be some set of >attribute variables. Or, of course, one could use the meta-programming >system of MBS to retrieve information at run-time about the structure >of objects; still, if possible, it would be a quite verbose and >error-prone way to create and execute instances (i.e. to USE those >methods which the given object apparently understands). >I think this all boils down to: BETA is statically typed (the only >kind of run-time type check is in reference assignment, everything >else is statically type-safe), and the notion of "reference to name" >is quite hard to integrate without compromising this type safety. >Soren Brandt (who proposed the attribute variables) might elaborate. > HopeThisHelps >-- >Erik Ernst eernst@daimi.aau.dk >Computer Science Department of Aarhus University, Denmark