lua-users home
lua-l archive

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


Le mer 29/11/2006 à 12:55 Fabien à écrit:
> > My last issue was with a class() function that create a class from
> > functions.
> 
> 
> This might interest you:
> 
> http://metalua.luaforge.net/samples/olua.lua.html
> 
> It's a Metalua module that adds a class syntax. It can be
> significantly simplified, and the implementation model of the classes
> can be changed as suits you best. It currently allows to write things
> like:
> [...] Some OO syntax

Thanks, that's interresting ... but object orientation is not my point
here. I have the same troubls with complex data description.

The lua way to describe a node in a tree is as follows

Node{
	attribute = value;
	...
}

But what if I want to create subnodes ? I can write something like :

parentNode{
	subNode{
		...
	};
	subNode{
		...
	};
	...
}

But what if subNode has not the same meaning when it is child of
parentNode and when it is parent itself. Imagine the fictive example :

N1{
	N2{...};
	N1{...};
}
N2{
	...
}

Now, root>N2 is not the same as root>N1>N2 and root>N1 is not the same
as root>N1>N1. It is not easily implementable. Now with the new syntax,
you can write :

in N1 do
	in N2 do ... end
	in N1 do ... end
end
in N2 do
	...
end

Because the code between do and end is a lua function, you can change
its environment and the N2 function in the global environment would not
be the same as the N2 function in the environment of a N1 node.

As you can see, the very basic code :

	f(function()
		return something
	end)

transforms to :

	in f do
		return something
	end

Personnaly, I prefer the second way

So, now, can someone comment the proposition ? Is it a good idea, are
there better ideas out there to impement that ?
pleaaaassseeee.

Mildred
-- 
Mildred       <xmpp:mildred@jabber.fr> <http://mildred632.free.fr/>
Clef GPG :    <hkp://pgp.mit.edu> ou <http://mildred632.free.fr/gpg_key>
Fingerprint : 197C A7E6 645B 4299 6D37 684B 6F9D A8D6 [9A7D 2E2B]