[comp.lang.modula2] procedure parameters and TRANSFER

rlc@uvacs.CS.VIRGINIA.EDU (Robert L. Chase) (09/13/87)

In setting up coroutines in Modula2, the NEWPROCESS procedure
requires that the PROC (coroutine) be a parameterless procedure.
Can anyone assist me with why that is the case? What is the 
underlying mechanism that requires this? 
 I ask, since in my sabbatical work (beginnings of OS research)
Bob Cook at UVA sets up coroutines etc as procedures that
have one integer parameter, then doesn't use NEWPROCESS and
TRANSFER, instead (since we were on Liliths at Virginia), using
some of the procedures and CODE procedures that Wirth published.
I need to implement same OS, and want to do it on a MAC (MAC II)
and thus need to do some assembly lang stuff to do a NEWPROCESS
and TRANSFER (or do I?).
 Any assistance would be appreciated.
~  ~/sign
----

Robert L. Chase                    INTERNET:  rlc@uvacs.cs.virginia.edu
Director of Academic Computing
Computer Center
Sweet Briar College                UUCP:      ...!mcnc!uvacs!rlc
PO BOX AK                                     ...!cbosgd!uvacs!rlc
Sweet Briar, VA 24595    
  (804) 381-6232
~p
A

-- 
Robert L. Chase, PO Box AK, Sweet Briar College, Sweet Briar, VA 24595
INTERNET:  rlc@uvacs.cs.virginia.edu
UUCP:  ...!mcnc!uvacs!rlc     or    ...!cbosgd!uvacs!rlc

alan@pdn.UUCP (Alan Lovejoy) (09/15/87)

In article <1966@uvacs.CS.VIRGINIA.EDU> rlc@uvacs.CS.VIRGINIA.EDU (Robert L. Chase) writes:
>In setting up coroutines in Modula2, the NEWPROCESS procedure
>requires that the PROC (coroutine) be a parameterless procedure.
>Can anyone assist me with why that is the case? What is the 
>underlying mechanism that requires this? 

The underlying mechanism that "requires this" is that a well-designed
language avoids complicating the life of a certain language and/or
compiler designer named Niklaus Wirth.

Specifically, the NEWPROCESS pseudo-procedure has the formal header
definition: PROCEDURE NEWPROCESS(p: PROC; workArea: ADDRESS;
				 workAreaSize: CARDINAL; process: ADDRESS);

and a parameter of type PROC has to be a parameterless procedure.  The
language has no facility for specifying a procedure with a generic 
argument profile, and to make a special case for NEWPROCESS means
more work for Niklaus Wirth as well as introducing an irregularity.

Personally, I think the NEWPROCESS procedure *should* be a special
case which allows procedures of any type, but its not my language.
An even better solution would be to change the semantics of NEWPROCESS
so that the PROCEDURE (MODULE) that invokes NEWPROCESS is the one that
gets instantiated as a process.  The formal definition would then be:
PROCEDURE NEWPROCESS(workArea: ADDRESS; size: CARDINAL; VAR process: ADDRESS).  
This makes it unnecessary to specify the source-proc, since it is now
known to be the caller.

Lacking such changes to the syntax of Modula-2, the simplest and least
elegant fix is to "pass" parameters via global variables. Ugh.

--alan@pdn