lua-users home
lua-l archive

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

> Yes, I'd like to *vehemently* protest about the included
> abomination of a bit library!
> It's INCOMPATIBLE to *all* other bit libraries out there! And it
> has nonsensical system-dependent semantics, esp. wrt. the number
> type. How on earth should one write portable code that way?
> Do you really want to repeat the learning curve that the lbitlib
> author and myself as the author of Lua BitOp had to go through?
> Have you read the lengthy page on portable bit operations
> semantics I wrote?
> I cannot understand what stops you from just dropping in the
> latest Lua BitOp and *be done*.
> [
> I strongly suggest to read "Hints on programming language design",
> by C.A.R. Hoare from 1973 (!):
> Especially chapter 12 (2) about "The language designer [...]":
>   "One thing he should not do is to include untried ideas of his own.
>   His task is consolidation, not innovation."
> ]

Your tone is rather offensive, but nevetheless I am going to answer
this message.

First, I read that paper, several times, along many years. I have great
respect for Tony Hoare, but he is not God. Most successful languages do
not follow this particular advice (I guess Java is the only exception ;).

About why we do not use BitOp: I see no reason why (a << 33) should not
be 0, or why (a << -1) should not be equal to (a >> 1). I have been
using shift operators for many years, and I too often miss this behavior
in C. I can undestand why C does not give it, but I cannot undestand why
Lua should not give it.

About the system-dependent semantics, I may be missing something,
but I do not see the problem. This library operates on bits; as long
as the result type is able to represent the 32 bits, is should make
no difference whether they are signed, unsigned, or packed inside a
double. Of course, if you do something like "if,y) < 0
...", then you will have system-dependent semantics. But, for me, this
operation already has an arbitrary semantics. What does it mean to ask
whether a bunch of bits is smaller than zero?

Of course we can argue about it, but not in the way you tone your

-- Roberto