OpenBSD port of dmd?

Peter Alexander peter.alexander.au at gmail.com
Sun Mar 18 11:09:40 PDT 2012


On Saturday, 17 March 2012 at 01:37:49 UTC, Andrei Alexandrescu 
wrote:
>>> This seems to accomplish little more than "well I didn't use 
>>> else".
>>>
>>> Again: what exactly is wrong with specialization?
>>>
>>
>> The advantage is, that when you write the code, you have _no 
>> idea_ what
>> platform/os it might need to run on in the future.  You 
>> _cannot_ know which
>> version is most appropriate for _all_ new platforms, or even 
>> if any of them
>> will work at all.
>
> Oh yes I do. Often I know every platform has e.g. getchar() so 
> I can use it. That will definitely work for everyone. Then, if 
> I get to optimize things for particular platforms, great. This 
> is the case for many artifacts.

version(PlatformX)
{
     return superfastgetchar();
}
else
{
     return getchar();
}

Later on, we add support for PlatformY, which also supports 
superfastgetchar(). If you write code as above then no one will 
notice. It will just happily use getchar() and suffer because of 
it. If you static assert on new platforms then it forces you to 
look at the code for each new platform added and think about what 
version would be best.

As Walter said, you can't know what version will be most 
appropriate for all new platforms.


More information about the Digitalmars-d mailing list