D const design rationale

Bill Baxter dnewsgroup at billbaxter.com
Tue Jun 26 13:54:10 PDT 2007


BCS wrote:
> Reply to Bill,
> 
>> I guess we're just quibbling over the definition of the "often" in
>> your statement "Optimization often makes the difference between a
>> successful project and a failure."
> 
> That reminds me of a thought I had a while ago: compilers are 
> interesting beasts because they are a program that deals with programs. 
> Not only that, but a compiler must be written to handle anything that is 
> allowable, not just stuff that is a good idea (as opposed to the 
> compiler that should be written only with code that is a good idea). 
> This starts looking like the point that if a compiler is going to be 
> used by some market where a few people need something, then the compiler 
> needs it even if most people in the market don't need it.
> 
> I'm not sure if this is even remarkable but I though it was kind of 
> interesting.

It's the same thing with library API design, too.  A good library needs 
to consider all possible use cases, even the ones that are wacky. 
Probably same thing with all code. Haven't you ever been at that point 
where you find yourself writing way too much code to handle some case 
that probably won't even come up?  It's just a result of not knowing 
what your input will be in advance.

--bb



More information about the Digitalmars-d mailing list