[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Re: Still cryptic OOP syntax
- From: Mark Hamburg <mhamburg@...>
- Date: Sun, 30 Jan 2005 22:34:59 -0800
I wrote a toy generic function system for Lua once. I'm not sure I still
have it. One interesting problem in building a real system is that generic
functions really want some notion of types and Lua doesn't define those
But if one did have types, then one could say things like:
GenericFunctions.addMethod( math.add, myAddMethod, type1, type2 )
Here math.add is a generic function that does appropriate dispatch based on
its argument types. To preserve efficiency, one could even specify that the
number plus number case couldn't be replaced so that the VM could continue
to special-case it.
One could use metatables as a proxy for types, but that has trouble in the
cases where we need per-object metatables.
on 1/30/05 6:39 PM, skaller at email@example.com wrote:
> On Mon, 2005-01-31 at 12:21, Jamie Webb wrote:
>>> YOu need n^2 routines for n types, which doesn't fit
>>> into the n methods OO allows... this kills OO as a
>>> programming methodology with a one line argument.
>> It's certainly one of the numerous flaws in Java, but I don't think
>> you can dismiss OO in general so easily. Surely in a dynamically typed
>> language nothing more than multiple dispatch is required?
> It depends exactly what you mean by that :)
> I mean PA's overload solution is just multiple
> dispatch .. and there's no OO there at all.