<html><body><div class="gmail_quote">
<div dir="ltr" class="gmail_attr">On Dec 15, 2024 at 5:15:33 PM, Jonas Maebe via fpc-pascal <<a href="mailto:fpc-pascal@lists.freepascal.org">fpc-pascal@lists.freepascal.org</a>> wrote:<br></div>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex" type="cite">
It's because unlike in Borland Pascal, procvars in ISO Pascal captured<br>the stack frame and allowed you to access local variables of the caller.<br>By only allowing the declaration in the procedure header, this ensured<br>the captured context could never escape the scope in which it was valid:<br>after the scope in which it was valid was exited, the declaration would<br>not longer exist either.<br><br>FPC does allow you to capture these outside the scope where they are<br>valid (using "is nested" procvar declarations), but the result is also<br>that you can call them once they are no longer valid.<br>
</blockquote>
</div>
<br>
<div dir="ltr">Ok that makes sense now. That’s interesting they crossed paths and never joined the two designs in any of the compilers.</div><div dir="ltr"><br></div><div dir="ltr">My opinion currently is that anonymous procedure types in parameters are ugly/less readable but are better than the alternative of declaring types that are only ever intended for a single procedure anyways. I find it makes lots of types like “TMyProcedureCallback”which are single use and just introduce extra names so I side with the ISO standard over Borland here.</div><div dir="ltr"><br></div><div dir="ltr">Also noteworthy is ISO standard can accommodate generics which Borland’s design can not. Did ISO standard allow pointer types in parameters too? It seems like an arbitrary choice to allow pointer types on fields but not parameters (same for procedures). Maybe another Borland idea? </div><div dir="ltr">
<br clear="all"><div><div class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr">Regards,</div> Ryan Joseph</div></div><br>
</div></body></html>