lua-users home
lua-l archive

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


Am 28.07.2015 um 05:45 schröbte Daurnimator:
In the faraway future, in whatever version of lua comes next:
It'd be nice if lua_topointer was exposed to lua code.
This would allow for users to get a unique value corresponding to a
given object.

Use cases:
   - __tostring metamethods that have previously needed a `rawtostring`
         (usually painstakingly created by removing the metatable and
then replacing it)

As an alternative, maybe we can have a new format specifier for `string.format` that calls `lua_topointer` on its argument (`%p` is still free I think) ...

   - common value for comparison by e.g. table.sort

That wouldn't do much good, since light userdata don't have `<` defined (and the C standard makes this operator difficult to implement).

Anyway, both use cases probably shouldn't depend on a debug function.


Philipp