[Gd-hackers] gtk interface: shorten identifiers, ... ?
Bruce Hoult
bruce at hoult.org
Mon Dec 4 01:59:10 CET 2006
On 12/4/06, Chris Page <chris at chris-page.org> wrote:
> I've often thought that we should consider either adding overloading--
> meaning that different numbers of required args would simply create
> different generic functions with the same user-visible name
How on earth would the compiler know which generic function to use?
> --or allow
> methods to require different numbers of required args as long as they
> require at least as many as the generic function, which must accept
> #rest, e.g.:
>
> define generic foo(req1, req2, #rest optional);
> define method foo(req1, req2, #rest optional) ... end;
> define method foo(req1, req2, req3, #rest optional) ... end;
> define method foo(req1, req2, req3, req4, #rest optional) ... end;
>
> These would be considered congruent and the number of arguments
> passed in would be considered when dispatching.
Doesn't seem very clean and I really dont' see how you'd implement it
to be fast unless the compiler exmapded it out to different GFs
internally depending on how many arguments were passsed, with the
functions with fewer "required" arguments having implicit <object>
specializations in the GFs for 3 or 4 arguments.
This could be done with macros right now.
More information about the hackers
mailing list