[prev in list] [next in list] [prev in thread] [next in thread] 

List:       lua-l
Subject:    Re: [NoW] Deja vu
From:       Philippe Verdy <verdy_p () wanadoo ! fr>
Date:       2019-08-12 10:38:25
Message-ID: CAGa7JC2xPe-9GK-p6itttZ6GoPCoNLfTRcRdz7aDn1hLCG4kDQ () mail ! gmail ! com
[Download RAW message or body]

No you can't! Every function is defined within a scope that always has many
visible variables in scope (and not just in its environment). Not removing
the visible variables that are not used by the function from the set of
upvalues to include in its new closure would be a strong error. And when
this set of used variables becomes empty, it makes no sense at all to
instanciate dynamically a new closure (function reference): it should be
static and created once by the compiler.


Le lun. 12 ao=C3=BBt 2019 =C3=A0 05:02, Kaj Eijlers <bizziboi@gmail.com> a =
=C3=A9crit :

> >> Moving functions out of a loop is not as simple as you think: the loop
> may not be visible at all and come from an invisible outer scope
>
> If you are not depending on an upvalue you can always return a reference
> to function that is defined outside the scope that's returning it and thu=
s
> return a the same version every time?
>

[Attachment #3 (text/html)]

<div dir="ltr">No you can&#39;t! Every function is defined within a scope that always \
has many visible variables in scope (and not just in its environment). Not removing \
the visible variables that are not used by the function from the set of upvalues to \
include in its new closure would be a strong error. And when this set of used \
variables becomes empty, it makes no sense at all to instanciate dynamically a new \
closure (function reference): it should be static and created once by the \
compiler.<div><br></div></div><br><div class="gmail_quote"><div dir="ltr" \
class="gmail_attr">Le  lun. 12 août 2019 à  05:02, Kaj Eijlers &lt;<a \
href="mailto:bizziboi@gmail.com">bizziboi@gmail.com</a>&gt; a écrit  \
:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px \
0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div \
dir="ltr">&gt;&gt;  Moving functions out of a loop is not as simple as you think: the \
loop may not be visible at all and come from an invisible outer \
scope<div><br></div><div>If you are not depending on an upvalue you can always return \
a reference to function that is defined outside the scope that&#39;s returning it and \
thus return a the same version every time?</div></div> </blockquote></div>



[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic