lua-users home
lua-l archive

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

Klaus Ripke wrote:

On Thursday 09 December 2004 16:41, John Paquin wrote:

So the question I'm asking is, how hard would it be to make a seperate
"int" data type?

basically creating new numeric types like complex, vectors,
fixed point or arbitrary precision bigints as userdata with
metatabled operator overloading is quite straightforward
-- at the price of some performance penalty, obviously.

Probably you'd choose int as builtin and make all others
nice "classes" (with all the math becoming methods of double).
That way you would be able to choose you number type for
the real calculations by pluging the appropriate lib, err, class.

Agreed. If and when I return to the world of FPU-less PDAs, I'm going to make Lua numbers be 32-bit integers and create a double library.

Well, after appropriate benchmarking, of course. Many of us spent many years programming Microsoft BASIC implementations such as Commodore BASIC and Applesoft without significant heartache at all the performance left on the table by using (5-byte) floats for everything.

An interesting thought experiment I indulge in frequently is:

Knowing what we know now about language design, user interfaces, and extensibility, what kind of programming environment would we create for the 8-bit microcomputers?

Scaling down is important. Let's say we have a luxurious 16k of 6502 ROM, and have to do *something* useful in 16k of RAM. (I'm picking 16k because the VIC-20 was sorta hopeless, and you needed about 12k to use Applesoft.) Oh, and secondary storage may be slow and far away---don't count on software virtual memory, as the user may only have a tape drive.

Before you ask, FORTH is not acceptable, as it's too easy to blow up the machine.