lua-users home
lua-l archive

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


Peter Hill:
> I'm having trouble trying to imagine a way to get the same functionality
> (which doesn't mean it can't be done of course!). As an example, let's try
> to implement complex numbers as an abstract type.

Eero Pajarre:
> This is a quick (late night) implementation of an idea I got,

Excellent! Thank you. I wasn't really sure it could be done.


> I think it has reasonable overhead. It is heavyweight for something as
> simple as a complex number, but maybe reasonable for something more
> complex. (I think that the cost of a small function is ok)

The overhead doesn't seem too bad. Each object is a function closure plus a
static variable. I notice that this method would also work in Lua4 using
upvalues instead.


> Btw, this is still not safe against someone who is actively trying to
> cheat

How so?

*thanks again*
Peter Hill.