[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Unnecessary New Closures
- From: "Patrick Donnelly" <batrick.donnelly@...>
- Date: Thu, 6 Sep 2007 04:42:37 -0600
I'm curious about a problem I encountered with this:
table.sort(sometable, function(a, b) return a < b end);
If this is executed repeatedly this creates a new closure every time.
Because, as I understand it, this function is compiled as a prototype
with no upvalues, why is a new closure created every time? Seems
unnecessary, let alone inefficient. Would it not be possible for the
lua compiler to just get the reference to the function (closure) and
"One of the lessons of history is that nothing is often a good thing
to do and always a clever thing to say."