<div dir="auto"><div><div class="gmail_quote"><div dir="ltr" class="gmail_attr">Ryan Joseph via fpc-pascal <<a href="mailto:fpc-pascal@lists.freepascal.org">fpc-pascal@lists.freepascal.org</a>> schrieb am Mi., 28. Apr. 2021, 17:53:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><br>
<br>
> On Apr 27, 2021, at 11:36 PM, Sven Barth <<a href="mailto:pascaldragon@googlemail.com" target="_blank" rel="noreferrer">pascaldragon@googlemail.com</a>> wrote:<br>
> <br>
> Anyway, it would in principle be possible to convert an anonymous function to a "is nested" function, but that will only come *after* the whole implementation is here so that the chance for messing that core functionality (!) up is reduced.<br>
<br>
Sorry I'm struggling with all these new terms myself. Yes that is what I'm proposing and what I demonstrated in that GitHub branch. We talked about this in 2018 but you said to wait until the "real thing" was finished so I let it be. I brought this up again now to say that when, and not before, the closures are finished and in trunk I will see how to integrate the "nested anonymous functions" into the new system. <br>
<br>
To clarify for myself, we have a few concepts here:<br>
<br>
- Closures: blocks which capture variables in scope and wrap them into a container (nested functions use a record I think and closures will use an interface).<br></blockquote></div></div><div dir="auto"><br></div><div dir="auto">Nested functions simply use the framepointer. They are using it like a record, but in essence it's simply the framepointer... </div><div dir="auto"><br></div><div dir="auto"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
- Anonymous procedures: Simply an anonymous procedure/function body which lacks a name and can be declared inside code blocks.<br></blockquote></div></div><div dir="auto"><br></div><div dir="auto">Correct. </div><div dir="auto"><br></div><div dir="auto"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
- 2 Procedure types: "reference to" and "is nested". On the caller side these are what control which kind of closure is used is used. Is that correct? So the anonymous function doesn't really become a closure until it's passed to a "reference to" or "is nested" variable.<br></blockquote></div></div><div dir="auto"><br></div><div dir="auto">To be precise there are two more: function/procedure variables (no special designator) and method variables ("of object"). Depending on what a anonymous function captures (or for the sake of it a nested function) it would be possible to assign it to such a type as well (for a function variable only global variables may be used, for a method variable additionally Self may be used). </div><div dir="auto"><br></div><div dir="auto"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">So once the current work is done we have 2 kinds of closures but only one of those is compatible with anonymous functions and this is why I want the other closures (nested functions) to have the same pair of functionality.<br></blockquote></div></div><div dir="auto"><br></div><div dir="auto">Once anonymous functions are supported we can improve their compatibility with other constructs. </div><div dir="auto"><br></div><div dir="auto">Regards, </div><div dir="auto">Sven </div><div dir="auto"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
</blockquote></div></div></div>