DMD 1.005 release

BCS BCS at pathlink.com
Wed Feb 7 11:48:43 PST 2007


Walter Bright wrote:
> 
> #if __GNUC__
> #include <pthreads.h>
> #else
> #include <windows.h>
> #endif
> 
> AAAARRRRRGGGGGHHHHH!!! That, my friends, is evil.

agreed.

> BCS wrote:
>>
>> version(RowMajor)
>>     x = table[i][j];
>> else // RowMinor
>>     x = table[j][i];
> 
> 
> int GetRow(i,j) { return table[i][j]; }
> 
> The function gets inlined.

The equivalent of this doesn't

version(RowMajor)
{
     x = 0
     for(i=0;i<max;i++)
	x+=table[i][j];
}
else // RowMinor
{
     x = 0
     for(i=0;i<max;i++)
	x+=table[j][i];
}

and IIRC this doesn't ether

version(X86) // avoid overflow in midpoint calculations
{
	asm
	{
		MOV low EAX;
		ADD EAX hi;
		RCR EAX 1;
		MOV EAX mid;
	}
}
else
{
	mid = (hi-low)/2 + low;
}

>>
>> ====You can't break across function calls
>>
>> switch(i)
>> {
>>     case 1:
>>         version(Baz)
>>             if(baz) break;
>>         else
>>             break;
>>     case 2:
>>
>>     ...// lots of un versioned code
>> }
> 
>     if (globalversion.baz && baz)
>         break;

The point is to have all of the versioning done by the time you link, 
that leaves a runtime check for version info.

> 
>> ====lots of version combinations
>>
>> version(Foo) i = foo(i);
>> version(Boo) i = boo(i);
>> version(Fig) i = fig(i);
>> version(Baz) i = baz(i);
>> version(Bar) i = bar(i);    //32 options???
> 
> 
> i = abc(i);    // a different abc is implemented for each version.

All 32 possibilities??? What if there are 16 independent versions? 
that's 64K functions! And no that is not an unlikely case, say "i" is a 
parse tree and we want to add different types of annotation depending on 
what features are enabled.

> 
>>
>> Are these valid concerns? Am I misunderstanding what you said?
> 
> 
> They are valid concerns, you're just used to thinking in terms of the C 
> preprocessor.

I have barely ever used CPP for that type of thing so I wasn't ever used 
to thinking that way in the first place.
<g>



More information about the Digitalmars-d-announce mailing list