Am Do., 15. Nov. 2018, 12:26 hat Marcos Douglas B. Santos <m...@delfire.net>
geschrieben:

> On Thu, Nov 15, 2018 at 8:15 AM Sven Barth via fpc-pascal
> <fpc-pascal@lists.freepascal.org> wrote:
> >
> > Am Do., 15. Nov. 2018, 10:17 hat Ryan Joseph <r...@thealchemistguild.com>
> geschrieben:
> >>
> >> Is passing nested procs outside of the calling scope relying on
> undefined behavior? It doesn’t seem like this should be allowed.
> >
> >
> > See the notes mentioned here:
> http://wiki.freepascal.org/FPC_New_Features_2.6.0#Support_for_nested_procedure_variables
> >
> > Don't know if it is documented as such, but if not, it should be.
>
> If I understood correctly, this can be used in all cases of anonymous
> functions, with the advantage to make the code more readable and
> "Pascalish".
> Am I right?
>

No, because function references (which is the name of the variables for
anonymous functions) store the captured variables in an automatically
created and managed object. Nested functions simply work on the stack. So
passing them outside of the context of the function they're declared in
will result in garbage.

Regards,
Sven

>
_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Reply via email to