[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: bitwise ops -- make them enums! (Re: what's wrong?)
- From: Asko Kauppi <askok@...>
- Date: Sun, 4 Sep 2005 15:58:53 +0300
io.popen being back is really Good News... hip, hip, hooray!!!
As to bitops, hex numbers et.al, I'd really like to see a permanent
solution that in my opinion goes way further than just that. Recent
LuaX releases experiment with built-in "enumeration" int32 types,
which in my opinion is The Way to Go. Reasons?
Simply giving bitwise operations to programmers is a no-no. C does
this, and its enumerations are way too soft to provide any kind of
safety nets for the poor fellows. The main issue is, a flag should
only be usable with values it was intended to be used with. You know
what I mean?
Now, in Lua there would be two ways to address this. Either do the
wrap-ups so that binary fields are represented to the application
programmer as tables (say, screen.format), or to use hard typed
enumerations. Perhaps these two could be combined, but I haven't
looked into that, yet.
n.b. normally the only place where enums are defined (within LuaX)
are the C modules. This comes from the simple reason that any
bitfields normally are used only in contact with C code. In Lua only
world, there are other ways.
Mike Pall kirjoitti 4.9.2005 kello 15.24:
The one good thing about Lua 5.1 alpha that hasn't been mentioned
yet: io.popen is back!
That said, I still want hex numbers and bit functions. I think
I'll make a patch ... :-)