-
Notifications
You must be signed in to change notification settings - Fork 24
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make constants typed #86
Comments
At first glance, this looks somewhat viable. But I think the best way to learn more is to prototype the change and see what works, what doesn't. But some consts won't fit in const TIMEOUT_IGNORED = 0xFFFFFFFFFFFFFFFF
It might be possible to achieve that in a different way, just by creating a helper that takes a GL constant value and returns its string representation. That way, it can even live in a separate package, one that people who don't want debug info (which increases binary size) can avoid. @errcw, what's your take on this idea? |
Fundamentally, the problem would be identifying function parameters that would take That said it would be possible to build a stringer that converts from constant value to constant name. |
I suspected that could be the case, making this not possible. Thanks for confirming. |
Ok, I got it.
I guess it would be handy if the stringer code is shipped with the library |
I think only it's viable to put it in the same package if not using it means it gets dead code eliminated. Otherwise, we'd be increasing all production binary sizes. |
While it is possible to achieve type safety for constants passed to GL functions, I think it would be a breaking change.
What I ask for is to declare a type, e.g.
type GLConst int32
and define constants asThen it would be possible to use
stringer
to generate the code which would convert a value (returned by gl.GetError, for example) to constant name. I think it would be pretty neat for debugging and exception displayingThe text was updated successfully, but these errors were encountered: