lua-users home
lua-l archive

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


On 11/18/2011 08:45 PM, Ignacio Burgueño wrote:
> 
> On Fri, Nov 18, 2011 at 10:43 PM, William C. Bubel <wcbubel@gmail.com
> <mailto:wcbubel@gmail.com>> wrote:
> 
>     On 11/18/2011 11:41 AM, GrayFace wrote:
>     > What I don't like about 5.2 is that 5.1 is cleaner in many ways.
>     > ...
>     > function definitions always produce a new function
> 
>     Can somebody clarify this for me? What's the situation in 5.2 where the
>     function keyword wouldn't produce a function object?
> 
> 
> function foo()
> 
>   local function bar()
>   end
> 
>   print(bar)
> end
> 
> foo()
> foo()
> 
> 
> In Lua 5.1, a call to function "foo" will create a new instance of
> function "bar" each time. Lua 5.2 will create only one instance if "bar"
> has the same upvalues each time.

This seems like a reasonable optimization. Is there a hidden gotcha that
GrayFace is concerned with that I'm not seeing? I suppose if you were
doing equality checks between functions to determine object identity,
you would get tripped up, but I was under the impression that tables
were the golden standard for objects.