[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Object system
- From: David Given <dg@...>
- Date: Mon, 6 Dec 2004 18:13:13 +0000
On Monday 06 December 2004 18:04, Brian Weed wrote:
> Raffaele Salmaso wrote:
> > The nice thing is that I've removed the ':' syntatic sugar, now you
> > must use only the '.' operator.
>
> Speeking of the colon, does anyone here have a patch for Lua that
> actually does allow the dot to be used in place of the colon for
> derefencing?
I'm not entirely sure what you mean here; do you mean you want to be able to
call methods using . (as in Raffaele's OO system)? Because you can't do this
without putting closures into the table, like Raffaele's doing.
(Incidentally, while putting closures into the table does allow you to call
methods using . --- which is a very neat trick, BTW, I'd never thought of
doing it like that --- it does mean that you can't get hold of a generic
method pointer. I've just written some code that does this:
object = create_myobject()
t = {method1 = object.method1, method2 = object.method2, method3 =
object.method3}
m = t.method1
o1.m(o1, params)
o2.m(o2, params)
o3.m(o3, params)
...where o1, o2 and o3 are known to be instances of myobject.)
--
+- David Given --McQ-+ "Hydrogen fusion, the sun makes shine
| dg@cowlark.com | Vascular pressure makes the ivy twine.
| (dg@tao-group.com) | Because of Rayleigh, the sky's so blue.
+- www.cowlark.com --+ Hormonal fixation is why I love you." --- Zarf