lua-users home
lua-l archive

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


> Mark Hamburg wrote:
> >The other thing this breaks is if one were using functions simply as
> > unique values. There are plenty of other ways to achieve that,
> > however.
> 
> All this thread is definitely above my head, but (assuming I
> understood correctly) removing the ability to use functions as table
> keys and unique identifiers looks confusing. Sounds as if functions
> would be degraded to "first class and a half" values.
> 
> Example: did I already call this function? I'd normally use
> "called[f] = true" to remember it. Or "called[f] = result" for
> memoization.

The idea is that Lua would unify functions that are really equal. Most
normal uses (e.g., both your examples) would work as expected. I guess
the only thing that would not work is when you create a function only
to be a unique identifier (as Mark pointed out, this is something you
could/should do with a table or a userdata), but I am not sure about
this.

The effects of this change would be something similar to those from
light C functions, although we assume that, usually, those programming
in C are more prepared to handle those subtleties.

-- Roberto