Path: news.daimi.aau.dk!sbrandt From: sbrandt@daimi.aau.dk (S|ren Brandt) Newsgroups: comp.lang.beta Subject: Re: How to obtain a ref. to current _component_ obj.? Date: 1 May 1995 13:16:05 GMT Organization: DAIMI, Computer Science Dept. at Aarhus University Lines: 80 Message-ID: <3o2mul$2vn@belfort.daimi.aau.dk> References: <3nj0if$6hh@fbi-news.informatik.uni-dortmund.de> NNTP-Posting-Host: quercus.daimi.aau.dk Keywords: component,current,this Thus spake warda@fbi-news (Armin M. Warda): >Why is the following illegal for the BETA-Compiler [Mjolner BETA System >version 5.0(2) for SUN-4]? > (# Process: > (# me: ^|Process; > do this(Process)[]->me[]; > INNER > #); > A: @|Process (# do 'A' -> putline #); > do A; > #) Because assignment between component and object references has not been implemented by the current compiler. It is easily handled, but has not been done. >This error message is displayed by the compiler: > THIS(Process)[]->me[] > ***** Illegal assignment/comparison of value, reference or repetition The following code provides a work-around for assigning component references to object references and vice versa. Please ignore that objectToComponent exploits undocumented low-level features of the compiler. INCLUDE '~beta/sysutils/v1.4/objinterface'; ---lib:attributes--- objectToComponent: (# o: ^Object; c: ^|Object; ato: @addressToObject; enter o[] do (if o[]<>NONE then (if (o[]->getGCField)//-6 then (if ((@@o->tos'%AdrGetLong')-24->tos'%AdrGetLong') //ComponentPTvalue then (@@c,(@@o->tos'%AdrGetLong')-24)->assignRef if); if); if); exit c[] #); example: (# o: ^Process; c: ^|Process; do ...; o[]->objectToComponent->c[]; ...; c[]->componentToObject->o[]; #); >Is there a construct to obtain a reference to the current _component_ object? >============================================================================= #) I'm not sure whether you want this to solve the problem above, or whether you need it for other purposes... If you are using systemenv, you can always get a reference to the currently executing component by reading the systemenv attribute "theActive". See "basicsystemenv.bet". If you are not using systemenv, there is currently no interface to get a reference to the current component object (although the information is of course available in the runtime system.) -- Soren >Is there a work-around for this problem? >======================================== >Yours sincerely, Armin. >--------------------------------------------------------------------- >Armin M. Warda >Universitaet Dortmund, Informatik IV, GB V, R.503, Tel: 0231-755-4824 >44221 Dortmund, Privat: , Tel: 0231-75-37-30 >WWW: "http://ls4-www.informatik.uni-dortmund.de/QM/MA/warda/pi.html" >PGP fingerprint = 66 C0 3E 8E D9 FE 61 77 DB 37 0D 40 36 53 71 6A