Algol 68 has nested procedures, with the convention that inner procedures 
can access the identifiers (like variables and parameters0 of the outer 
ones.  These have to be accessed by pointers to outer activation records.

Now the stackdata will do fine for normal variables.   Given a pointer to 
any of the contents. the rest can easily be accessed.  In my compiler, 
I'm statically calculating the exact integer offsets; as a result I need 
only one label in the stackdata, and use computed offsets for the rest.

But parameters are another matter.  They don't have addresses.  So I'm 
stuck with copying them into the stackdata on entry (simplest solution, 
but probably not fast).  Or being innovative.

Now I could, at the call, pack all the parameters into a struct and 
passing that as a parameter.  No, wait.  I still don't have an address.  
I could pack them into a struct into the stackdata at the call and pass 
the address as a parameter.  I could stick that address into a register, 
into a static display, include it as part of the data structure for a 
nested procedure, and so on.

Is this really the way it's intended to implement nested procedures and 
parameters, or am I missing something obvious?

-- hendrik

_______________________________________________
Cminusminus mailing list
[email protected]
https://cminusminus.org/mailman/listinfo/cminusminus

Reply via email to