lua-users home
lua-l archive

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

On Apr 14, (Mark Ian Barlow) wrote:
> Fair enough, Norman; my simulation of a hashed case construct only works
> at global scope because nested functions are illegal. What I really want
> is to have a table of *blocks*. Perhaps I can hack a better example with
> Lua 3.0alpha's new userdata type... I'm just about to download it.

It would be nice (IMO) to be able to declare blocks _and_ anonymous
functions inline. I would like to be able to do the following:

a_location = { x = 0, y = 0
swap = function(self) 
   self.x,self.y = self.y,self.x;
end ,
dup = function(self)
   self.x = self.y;

Or the equivilant. (I don't care about the syntax). Right now, if you
want to setup an "object" out of a table which has data and methods,
you have to do it separately (again, please correct me if this is wrong):

a_location = { x = 0, y = 0}
function a_location:swap()
   self.x,self.y = self.y,self.x;
function a_location:dup()
    self.x = self.y

> Meanwhile I'll look into benchmarking the global-only version for different
> sized case lists. I'll post anything interesting I find out. As LHF said
> we won't be getting a case construct just yet this is a bit academic I
> suppose, but what the heck...

I think this should yeild some interesting results.

David Jeske (N9LCA)   +   +