[M3devel] m3cc static chain stuff

Mika Nystrom mika at async.async.caltech.edu
Thu May 27 02:11:33 CEST 2010


Jay K writes:
...
>=20
> Why are parameters different than variables?
> Can't I store a parameter in a variable? Even a local one?=20
> Maybe not=2C because that might have bad "lifetime" and bad "safety"?
...

No you can't assign a procedure parameter that came from an inner
procedure to a variable.

In the below example, the activation record for A is already destroyed
when I call b().  It's still there in C.

TYPE P = PROCEDURE();

VAR a,b : P;

PROCEDURE A() =

  PROCEDURE B() = BEGIN END B;

  PROCEDURE C(p : P) = BEGIN p() END C;

  BEGIN
    C(B);   (* OK *)
    b := B; (* BAD! *)
  END A;

BEGIN
  a := A;
  a(); (* OK *)
  b(); (* ERROR *)
END.

The runtime does check for this.  It aborts at (* BAD! *)

  
    Mika



More information about the M3devel mailing list