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: 15 Nov 1994 12:31:15 GMT Organization: DAIMI, Computer Science Dept. at Aarhus University Lines: 93 Message-ID: <3aa9mj$kc3@belfort.daimi.aau.dk> References: <39tqrf$q5m@poseidon.uni-paderborn.de> NNTP-Posting-Host: blanche.daimi.aau.dk Something went wrong in my previous posting, so here it is again. Sorry for the inconvenience. >> "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 (like foo##) 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, to som extend, 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". See Gregor Kiczales et al.: The Art of the Metaobject Protocol, MIT Press). 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. In contrast, the current implementation of BETA is based on a traditional edit-compile-execute cycle, which means that a lot of information is no longer directly accessible to the running program. One of the advantages of statically typed languages like BETA as compared to CLOS and SELF, is the ability to produce small and efficient executables. By using type inferencing, this has recently been made possible for dynamically typed languages as well (See e.g. OOPSLA'94: Ole Agesen: Sifting Out the Gold). However, the use of reflectional language capabilities in general and SELF Mirrors in particular, currently breaks the type inferencing algorithm used. Thus, the ability to produce efficient and tight executables from dynamically typed languages seems to be affected by the use of meta object protocols. By using the Mjolner BETA meta programming system (MPS), some of the introspectional (the ability to "look into" a running program and see what is going on) capabilities of e.g. the MOP may be retained in BETA. This is done in e.g. the debugger and in the objectbrowser library in order to display objects and program state in source level terms. Unfortunately this use of MPS still requires detailed (inside) knowledge of the underlying implementation, and is therefore not a generally applicable solution. The main problem, which is currently not supported by any public interface, is to map the runtime representation of the objects pattern into the corresponding abstract syntax tree (AST) node. The information in this AST node may then be used to access the state of the object, but only in a low-level and type unsafe way using undocumented compiler features. Now, Erik mentioned that I have done some work on a BETA language construct called "attribute references". The purpose of attribute references is exactly to reify the concept of pattern attributes in order to turn them into first class language citizens. These attribute references are actually a very important part of a meta object protocol for BETA on which I am currently working. Using the attribute reference language construct, this meta object protocol allows you to express what you need, including: >> Another question is: Can I determine at runtime which >> methods an object understands ? However, it is not clear whether this meta object protocol will ever make it into the language. So, in the short term, the only possibility is to use pattern variables and possibly the Mjolner BETA Meta Programming System. Cheers, Soren -------------------------------------------------------------------------- Soren Brandt, Computer Science Department, Aarhus University Ny Munkegade 116, DK-8000 Aarhus C, Denmark. E-mail: sbrandt@daimi.aau.dk, Phone: +45 89 42 32 57, Fax: +45 89 42 32 55 --------------------------------------------------------------------------