lua-users home
lua-l archive

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


Rene Rebe <rene@exactcode.de> writes:
>> There are better ways to write that, and you should use them...
>> expecting fractions to silently be dropped is just plain dodgy.
>> 
>> [e.g., = bit.band (bit.rshift (0xffff, 8), 0xff) ]
>
> I know this and all the details. Been there, done that.

... and yet you're still using bad code like you quoted?

> I already wrote that the concern is about least surprise and coding
> style. I do not consider using bit.Xshift or math.{round,ceil,floor}
> everywhere to be especially beautiful nor readable (reviewable,
> maintainable) code.

If you're operating on an integer value that, you expect to use as a
bitmask etc, then using integer operations with well-defined bit-level
behavior leads to _less_ surprising behavior.

-Miles

-- 
Justice, n. A commodity which in a more or less adulterated condition the
State sells to the citizen as a reward for his allegiance, taxes and personal
service.