[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: boolean operators
- From: Sam Roberts <sroberts@...>
- Date: Thu, 21 Sep 2006 14:32:40 -0700
On Thu, Sep 21, 2006 at 04:44:41PM -0300, Luiz Henrique de Figueiredo wrote:
> > Operators would make things more convenient, but I'd be OK
> > with having a bitwise operations library...
> I think the real point of Roberto's original question was how bitwise
> operations would work, be they operators or library functions. More
> precisely, should bitwise operations work only over integers (what you
> "2.5 | 1" mean?) or should they work over strings (which would then be
> seen as bit arrays)?
How about both! :-)
Seriously, when thinking of bits in the abstract, like if implementing
the binary algorithm to solve the Towers of Hanoi [*], setting them in
strings could be useful.
When interacting with C libs, setting in numbers is what's needed.
I wonder if there is a perspective difference operating here. Lua is an
"extensible" "extension" language.
>From the extendable point of view lack of bit operations isn't so
surprising, they are pretty easy to add and if they only come up when
solving the Tower of Hanoi, they aren't exactly core language
facilities. Easy to add as functions, anyhow, if you want operators you
are into wizard territory.
>From an extension point of view, when I'm using lua to extend my C
libraries, I find lack of a facility thats is so useful when extending C
to be slightly surprising, since in general much of lua seems carefully
designed to make what interacting with C easy and powerful (upvalues,
environments specifically useful to C functions, etc.).