Sane API design (AKA C's #ifdef hell)

Kagamin spam at here.lot
Mon Apr 20 19:19:54 UTC 2026


On Saturday, 18 April 2026 at 10:13:02 UTC, libxmoc wrote:
>> ```D
>> enum glSupport = (){
>> 	version(GL_46)       return GLSupport.gl46;
>> 	else version(GL_45)  return GLSupport.gl45;
>> 	else version(GL_44)  return GLSupport.gl44;
>> 	else version(GL_43)  return GLSupport.gl43;
>> 	else version(GL_42)  return GLSupport.gl42;
>> 	else version(GL_41)  return GLSupport.gl41;
>> 	else version(GL_40)  return GLSupport.gl40;
>> 	else version(GL_33)  return GLSupport.gl33;
>> 	else version(GL_32)  return GLSupport.gl32;
>> 	else version(GL_31)  return GLSupport.gl31;
>> 	else version(GL_30)  return GLSupport.gl30;
>> 	else                 return GLSupport.gl21;
>> }();
>> ```
>
> I'm not a fan of this mindset, both are valuable, besides, this 
> is exactly the problem. When the idiomatic answer to a problem 
> is hack.., we need to kill this workaround culture and give 
> people something that actually works.

AIU that version block is unnecessary, the author just wanted to 
do it, the docs say when you select opengl 4.6, it gives you not 
4.6, but all versions from 1.0 to 4.6.


More information about the Digitalmars-d mailing list