[Gd-hackers] gtk interface: shorten identifiers, ... ?

Mike Austin mike_ekim at yahoo.com
Wed Nov 29 08:51:31 CET 2006


Bruce Hoult wrote:
> On 11/29/06, Danny Milosavljevic <danny_milo at yahoo.com> wrote:
>> Does that mean it doesn't support "overloading" properly?
>> I mean its a nice idea to have classes not introduce their own namespace
>> (since that can be found out by the argument types), but all the methods of
>> different objects which coincidencially had the same name would need to
>> have the same number of arguments as well? That's pretty improbable :)
> 
> They can't "coincidentally have the same name".  The name of a method
> is actually the name of the Generic Function that the method is added
> to.  All methods in a Generic Function have to be congruent.
> 
> So Dylan doesn't have casual overloading of unrelated functions.
> 
> If you need to use several classes together that were developed
> independently and have coincidentally the same function names then
> you'd rename one or both of them on import.

There is a way around this, one of which Bruce will cringe because I mentioned 
it before. :)

Define your object specific method like this:

define method window-foo(window, a, b, c)
end method;

Now define a generic function which dispatches on one argument, and return the 
actual curried function you want to call:

define method foo(window :: <window>)
   return curry(window-foo, window);
end method;

window.foo returns the curried function you want to call, and

window.foo(1, 2, 3);

calls it.  You will still run into name clashes, but not with your defined 
functions.  The above is the same as window(foo)(1, 2, 3).

Yes, it's hacky.  But isn't anything experimental?


Yes, long time no hear, I know. :)
Mike




More information about the hackers mailing list