|
Am 10.11.2016 um 16:44 schröbte Daurnimator:
In a large number of C bindings, people end up writing a __tostring that simply does what I mentioned. e.g. - https://github.com/LuaDist/lrandom/blob/557814218d84db4d2991e86e1eb99fe9c5d65939/lrandom.c#L87 - https://github.com/daurnimator/lua-psl/blob/54a8a7875795d67d535f2dd8496a29dfe3885878/psl/psl.c#L62 - https://github.com/luvit/luv/blob/4977c67659cda9f2929b032c9ec7b7491deb63f3/src/req.c#L25
For the record: I do that as well for some of my libraries. But I usually strip prefixes because I use `modulename.typename` for `luaL_newmetatable()` to minimize conflicts and I want to keep the output of `__tostring` significantly smaller than the length of a terminal line.
For those that don't, they often end up doing a poor imitation (e.g. using a delimiter other than ": ", or surrounding in some token). Which results in unnecessary non-uniformity.
Lua file handles currently use "file (0xdeadbeef)" (i.e. no colon but extra parentheses). So that would be "fixed" as a bonus ...
Philipp