[fpc-pascal] Procedural parameters

Jonas Maebe jonas at freepascal.org
Sun Dec 15 11:15:33 CET 2024


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 
> <fpc-pascal at lists.freepascal.org 
> <mailto:fpc-pascal at lists.freepascal.org>> 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


More information about the fpc-pascal mailing list