OpenBSD port of dmd?

Alex Rønne Petersen xtzgzorex at gmail.com
Fri Mar 16 19:10:48 PDT 2012


On 17-03-2012 02:16, Daniel Murphy wrote:
> "Andrei Alexandrescu"<SeeWebsiteForEmail at erdani.org>  wrote in message
> news:jk0naq$257e$1 at digitalmars.com...
>>
>> But why duplicate doItSlowWay(); which may be an arbitrarily long
>> sequence?
>
> If duplicating that block is a problem, there are other ways to do it.
>
> version(ThisOS)
> {
>     version = FastWayA;
> }
> else version(ThatOS)
> {
>     version = FastWayB;
> }
> else version(SomeOS)
> {
>     version = SlowWay;
> }
> else version(OtherOS)
> {
>     version = SlowWay;
> }
> else
>     static assert(0, "OS not implemented");
>
> version(FastWayA)
> {
> ....
> }
> else version (FastWayB)
> {
> ....
> }
> else version (SlowWay)
> {
> ....
> }
>
>
>>
>> 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.  The only time to make this decision is when implementing
> support for a specific platform, and this pattern forces you to consider
> each place where platform specific behaviour is required.  When doing things
> like this, 100 false positives are much faster to fix than a single false
> negative causing wrong code/corruption.
>
>

I think this post is basically proof that we need logical and/or in 
version statements. I'm just putting that out there....

-- 
- Alex


More information about the Digitalmars-d mailing list