Pretty much. I'd expect to see:

version (linux) {
    // optimized impl
} else version (OSX) {
    version = UseDefault;
} else {
    static assert(false, "unknown platform");
}
version (UseDefault) {
    ...
}

This way, new platforms have to be evaluated, but once they are they can all 
share whatever common implementation is the default. 

On Mar 17, 2012, at 3:31 AM, Alix Pexton <[email protected]> wrote:

> I think Walter and Andrei are both right, just about different things.
> 
> I think Walter is right that there is no such thing as a default 
> implementation when it comes to compatibility with the host environment, and 
> asserting is the best course of action.
> 
> I think Andrei is right that when a particular environment has some 
> advantageous alternate implementation of a feature it can be used while 
> leaving the default for the cases where said feature is unavailable.
> 
> Walter is concerned with compatibility, Andrei with opportunistic 
> optimisation.
> 
> Knowing how to tell the difference is the real trick, and that is often a 
> much harder thing to pin down. Code that potentially needs to be different on 
> every platform should assert when the platform is unrecognised. Code which is 
> specialised for just a few platforms and has a "known good" default can use 
> else to provide said default. When unsure, assert is the more cautious option.
> 
> A...

Reply via email to