I'm running into the following:
fn someFunc(state: *lua.Lua) i32 {
// Pointer here is `* const anyopaque`
const pointer = state.toPointer(index) catch return 0;
// Do some stuff
// Save values into the table using that pointer
// This requires `* anyopaque`, so it discards the const qualifier.
state.pushLightUserData(pointer);
// Use the userdata in other lua apis
return 1; // final stack size, for example
}
Essentially the toPointer returns a pointer to a constant, but other apis expect just an anyopaque pointer. This requires me to do a bunch of @constCast anytime I want to use the pointer returned by the lua api.
It would be nice if there could be some consistency here. Either toPointer should return a pointer to mutable (which seems to be what the rest of the api expects), or the others should be const.
From a user perspective, I would expect toPointer to return a pointer to a mutable anyopaque because odds are I will want to further mess with the value.
I'm running into the following:
Essentially the
toPointerreturns a pointer to a constant, but other apis expect just an anyopaque pointer. This requires me to do a bunch of@constCastanytime I want to use the pointer returned by the lua api.It would be nice if there could be some consistency here. Either
toPointershould return a pointer to mutable (which seems to be what the rest of the api expects), or the others should be const.From a user perspective, I would expect
toPointerto return a pointer to a mutableanyopaquebecause odds are I will want to further mess with the value.