Re: Procedural parameters
Jonas Maebe via fpc-pascal <[email protected]>
| Newsgroups | gmane.comp.compilers.free-pascal.general |
|---|---|
| Message-ID | <[email protected]> |
On 15/12/2024 07:01, Hairy Pixels via fpc-pascal wrote: > On Dec 15, 2024 at 12:21:29 PM, Adriaan van Os via fpc-pascal > <[email protected] > <mailto:[email protected]>> wrote: >> You mean the original pascal only allowed function declarations to be >> parameter types? >> >> Yes. And it is still true in the ISO 7185 Pascal standard. > > That doesn’t make any more sense than only allowing them as type > declarations. It's because unlike in Borland Pascal, procvars in ISO Pascal captured the stack frame and allowed you to access local variables of the caller. By only allowing the declaration in the procedure header, this ensured the captured context could never escape the scope in which it was valid: after the scope in which it was valid was exited, the declaration would not longer exist either. FPC does allow you to capture these outside the scope where they are valid (using "is nested" procvar declarations), but the result is also that you can call them once they are no longer valid. Jonas _______________________________________________ fpc-pascal maillist - [email protected] https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal