lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


On 9/6/07, Thomas Harning Jr. <harningt@gmail.com> wrote:
> To clarify... someone could do a setfenv on the function causing its
> environment to be different, even though there's no upvalues.  Even if
> the function/closure itself doesn't touch the environment, it can
> still be used by external functions.  Perhaps a method to mark a
> function as being 'locked' and disable changing its environment or
> using upvalues could be an option...  However that is probably much
> more work than its worth...
>
> --
> Thomas Harning Jr.
>

Whether or not the function is anonymous (by that I mean, whether or
not it can be saved to some global value by the function you pass it
to as an argument) seems irrelevant to whether a new closure should be
made. The function's operation is orthogonal to the environment, where
the closure was made, etc. (all because there are no upvalues). Even
if the function relied on the global environment, I don't see a reason
for a new closure. If it's too difficult/costly to implement that's
one thing, but I don't see a theoretical reason for creating a new
closure over a function with no upvalues.

-- 
-Patrick Donnelly

"One of the lessons of history is that nothing is often a good thing
to do and always a clever thing to say."

-Will Durant