process (was: selfUnit)

Jecel Assumpcao Jr jecel at merlintec.com
Mon Jun 17 21:23:22 UTC 2002


On Sunday 16 June 2002 04:39, Thorsten Dittmar wrote:
> On 6/13/02 11:55 PM, "Jecel Assumpcao Jr" <jecel at merlintec.com> wrote:
> > [make new process prototype]
>
> This way does not work at all. Try it out, make a unchanged new
> prototype of process.

I tried it in Self 4.1.5 in Sparc and it seemed to work, so I tried it 
again in 4.1.2alpha in Linux and again got the expected results. Note 
that I wouldn't have been surprised if the VM had crashed as I had 
never actually tried it before.

I started out by adding this slots to 'globals':

             selfUnitProcess = process _Clone

I decided to use the raw primitive instead of risking any of the 'copy' 
method variations and that might have made a difference.

> Then use
>
> | p |
>
> p: selfUnitProcess copySend:
>  message copy   receiver: 1
>                 Selector: even.
> p resume waitForSuspension.
>
> You will always run into a vm error.

It should have been 'even' above or you will be sending the even message 
to 'shell' (depending on where you typed this) and the result of that 
will be the selector in the new process.

First I executed the above code but with 'process' instead of 
'selfUnitProcess' just to see what I would get. Then I tried again with 
'selfUnitProcess' and the result looked exactly the same. Then I added 
this slot to selfUnitProcess:

   errList <- list copyRemoveAll

and the name of selfUnitProcess was changed from "a process (ready 
process: scheduler" to "an object (ready process: scheduler)". 
Executing your expression a third time resulted in a new object that 
also had an 'errList' slot (sharing a value with selfUnitProcess, which 
is wrong. The 'copy' methods would have to be changed to correct this).

> So I looked closer to:
> > some applications that need it can make use of the the
> > 'onNonLocalReturn:' and 'onReturn:' methods in traits block.
>
> Please correct me when I'm wrong, my understanding of
> 'onNonLocalReturn:' is, that when at any time during the evaluation
> of the receiver block an error occurs the evaluation will be aborted
> and the argument block will be evaluated. Is this correct?

No, it just intercepts attempts to to a non local return from the block. 
This can be used in some cases where you would use "ensure:" in a 
system with exceptions, but won't handle any errors.

> [1/0] onNonLocalReturn: ['nice try']
>
> Brings up a debugger, not a string outliner.

I did mention that it wouldn't help you ;-)

These examples are more interesting:

  [ 1 ] onNonLocalReturn: [ 'nice try' ]

  [ ^ 1 ] onNonLocalReturn: [ 'nice try' ]

The first will return 1 and the second 'nice try'. This can be used to 
ensure that a file is closed even if a nonLocalReturn attempts to 
unwind the code past the point where the file was opened. I shouldn't 
have made such an unclear comment, sorry.

-- Jecel



More information about the Self-interest mailing list