Path: news.daimi.aau.dk!glad From: "S\xren Brandt" Newsgroups: comp.lang.beta Subject: Re: THIS and COMPONENTs Date: 26 Jul 1996 12:25:45 GMT Organization: DAIMI, Computer Science Dept. at Aarhus University Lines: 84 Approved: mailtonews@daimi.aau.dk Distribution: world Message-ID: <4tadg9$smm@gjallar.daimi.aau.dk> NNTP-Posting-Host: daimi.daimi.aau.dk Ah, well. It seems that I misunderstood your request. Below is the requested "objectToComponent". Please ignore that objectToComponent exploits undocumented low-level features of the compiler. If the entered object is not a component, "objectToComponent" will return NONE. 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[]; #); Hope this is of more help than my previous reply. -- Soren > No, it is not. I am not using the systems library, I am controlling > the scheduling of the co-routines myself (which might be the wrong > approach, but was what I wanted to do - to make the simulation > scheduler directly). I believe that there is no such mechanism (to > obtain the currently executing co-routine), which is why the basic > system library has a variable "theActive" (in my scheduler I called it > currentEntity). > > The BETA S.fork is now S[]->fork because it is not possible to write > it as: > System: > (# ... > fork : > (# do ... > this(system)[] -> Scheduler.queue > #) > #) > > (Or whatever the scheduler is called). > > Because Scheduler.queue will expect something qualified as > "^|System[]" but this(system)[] is an item, not a component. > > Therefore fork is implemented to recieve a co-routine reference, > which avoids the problem of "casting" between items and components. > > I would like to do "this(|System)[]" or similar. > > But I hope there is a way anyway, it would look better. > > In the "objinterface" library I have found the following two > procedures. What I lack is the third which could have been named > "objectToComponent" > > isComponent: BooleanValue > (* Exits true if obj is a component. *) > (# obj: ^Object; > enter obj[] > <> > #); > > componentToObject: > (* Exits the item part of the object entered *) > (# comp: ^|Object; > obj: ^Object; > enter comp[] > do <> > exit obj[] > #);