Path: news.daimi.aau.dk!news.uni-c.dk!newsfeed.sunet.se!news00.sunet.se!sunic!02-newsfeed.univie.ac.at!paladin.american.edu!news.ecn.uoknor.edu!munnari.OZ.AU!comp.vuw.ac.nz!canterbury.ac.nz!usenet From: kasper@pukeko.cosc.canterbury.ac.nz (Kasper Osterbye) Newsgroups: comp.lang.beta Subject: Re: THIS and COMPONENTs Date: 26 Jul 1996 00:14:14 GMT Organization: University of Canterbury Lines: 66 Distribution: world Message-ID: References: <4t0s10$jrs@gjallar.daimi.aau.dk> NNTP-Posting-Host: 132.181.12.13 In-reply-to: "S\xren Brandt"'s message of 22 Jul 1996 21:32:16 GMT In article <4t0s10$jrs@gjallar.daimi.aau.dk> "S\xren Brandt" writes: > Kasper Osterbye wrote: > > > > Hi, > > > > Is there a way to obtain a referece to the currently executing > > co-routine? > > Yes. The systemenv pattern (in basicsystemenv.bet) contains > the following declaration: > > theActive: ^|sysHead; > > which is exactly what you are asking for. 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[] #);