> 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... 
 > 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 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?

We expect that unlike the languages of the past, the languages of the
future will either not have nested procedures or will have first-class
nested procedures.  So if you care about performance, you should do an
escape analysis (pretty easy) to see which variables have to be
captured on the stack and at what program points.  The rest of the
time you should keep those variables in registers and let the register
allocator do its job.

If you don't care about performance then passing a pointer to a struct
is as easy as any other strategy and simpler than most.

If you've missed anything obvious, I've missed it too.


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

Reply via email to