<div dir="auto"><div><div class="gmail_quote"><div dir="ltr" class="gmail_attr">Ondrej Pokorny via fpc-pascal <<a href="mailto:fpc-pascal@lists.freepascal.org">fpc-pascal@lists.freepascal.org</a>> schrieb am So., 11. Sep. 2022, 12:18:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
  
    
  
  <div>
    <div>Am 11.09.2022 um 11:26 schrieb Sven
      Barth via fpc-pascal:<br>
    </div>
    <blockquote type="cite">
      
      <div dir="auto">
        <div>
          <div class="gmail_quote">
            <div dir="ltr" class="gmail_attr">Hairy Pixels <<a href="mailto:genericptr@gmail.com" target="_blank" rel="noreferrer">genericptr@gmail.com</a>>
              schrieb am Sa., 10. Sep. 2022, 03:21:<br>
            </div>
            <blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><br>
              <br>
              > On Sep 9, 2022, at 4:48 PM, Sven Barth <<a href="mailto:pascaldragon@googlemail.com" rel="noreferrer noreferrer" target="_blank">pascaldragon@googlemail.com</a>>
              wrote:<br>
              > <br>
              > How about you simply report such corruptions as bugs?
              I can always close them as "not a bug" or duplicate if
              necessary. <br>
              > <br>
              <br>
              Well I thought the data may have been saved on the stack
              and thus lost when the function exits. What is the
              expected behavior for passing these outside of the calling
              scope?<br>
            </blockquote>
          </div>
        </div>
        <div dir="auto"><br>
        </div>
        <div dir="auto">Looking at your example again - I'm only on my
          phone currently - it's indeed your fault because the state
          passed to a nested function variable does *not* survive the
          stack frame it belongs to. That's where function references
          shine, because there the state *does* survive.</div>
      </div>
    </blockquote>
    <p>Shouldn't this assignment be forbidden?</p>
    <pre>type
  TProc = procedure is nested;
function TestNested: TProc;
begin
  result := procedure // why is this possible?
  begin
    writeln(data);
  end;

It is not a nested function but an anonymous one.</pre></div></blockquote></div></div><div dir="auto"><br></div><div dir="auto">And? An anonymous function is assignment compatible to multiple left sides depending on what it captures. See my announcement mail. </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"><div><pre>
</pre></div>
</blockquote></div></div></div>