Cumbersome overloading of mixed-in functions

Chris Nicholson-Sauls ibisbasenji at gmail.com
Sun Aug 20 01:40:24 PDT 2006


nobody wrote:
> kris wrote:
> 
>> Jarrett Billingsley wrote:
>>
>>> Say I want to add a bunch of (virtual) methods to a class.  All these 
>>> methods do very similar things, just on different types.  Hmm, sounds 
>>> like a job for a template.
>>
>>
>> Better to do it all manually and save yourself the grief. Mixin should 
>> perhaps be removed from the language until such time that it works in 
>> a reasonable manner :(
> 
> 
> Just a little while ago I posed a question to D.learn about implementing 
> all the permutations possible of RGB, HSL, RGBA and HSLA. The numbers 
> from that post:
> 
>     3! + 3! + 4! + 4! = 60 types
>    (3! + 3! + 4! + 4!)^2 = 3600 opAssigns
> 
> Certainly manually is not really an option here.

Right now, in cases such as this, the best option seems to be writing a simple source 
generator to cough up the code into a file.  Usually the time/energy spent writing the 
generator program is reasonably less than manually typing them all out.

-- Chris Nicholson-Sauls



More information about the Digitalmars-d mailing list