[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Numerical constants
- From: Thomas Lauer <thomas.lauer@...>
- Date: Thu, 24 May 2007 17:58:54 +0100
"Jerome Vuarand" <firstname.lastname@example.org> wrote:
> For my OpenGL and Win32 API bindings, I went down the string route.
> Bitwise operators and bit mask constants are used most of the time as a
> hack to emulate a boolean set, I don't see any good reason (beyond
> speed) to expose such cumbersome interface to a Lua programmer.
So far I agree. This incessant fiddling with bit masks is violating all
common sense. In all fairness, this is not a Microsoft-specific illness:
pcre, my favourite regex library, uses bit masks left, right and middle.
> little more complicated for Win32, since there are many overlapping
> constant sets with each a different prefix and a different C type, and
> some API functions use sometimes a combination of several of these sets.
It is here that I start to see problems, especially with performance.
Many big sets of constants mean lots of functions to do the translation
between native code and Lua. This costs lots of memory and lots of CPU
cycles. (And it probably doesn't help that I've been exposed to this
bit-fiddling business for too long... in a sense I am just "too used" to
Luiz' token filter idea is a clever solution to that dilemma (I have
just seen that Lua will actually fold multiple constants into one value,
so this route looks very attractive indeed).
But thank you for your input: I will have a good night's sleep over this
mess and then we'll see:-)
web : http://thomaslauer.com/start