<p dir="ltr"><br>
On 14 Mar 2014 18:30, "Paulo Pinto" <<a href="mailto:pjmlp@progtools.org">pjmlp@progtools.org</a>> wrote:<br>
><br>
> Am 14.03.2014 19:06, schrieb Iain Buclaw:<br>
>><br>
>> On 14 March 2014 17:53, Walter Bright <<a href="mailto:newshound2@digitalmars.com">newshound2@digitalmars.com</a>> wrote:<br>
>>><br>
>>> On 3/14/2014 10:26 AM, Johannes Pfau wrote:<br>
>>>><br>
>>>><br>
>>>> I use manifest constants instead of version identifiers as well. If a<br>
>>>> version identifier affects the public API/ABI of a library, then the<br>
>>>> library and all code using the library always have to be compiled with<br>
>>>> the same version switches(inlining and templates make this an even<br>
>>>> bigger problem). This is not only inconvenient, it's also easy to think<br>
>>>> of examples where the problem will only show up as crashes at runtime.<br>
>>>> The only reason why that's not an issue in phobos/druntime is that we<br>
>>>> only use compiler defined versions there, but user defined versions are<br>
>>>> almost unusable.<br>
>>><br>
>>><br>
>>><br>
>>> Use this method:<br>
>>><br>
>>><br>
>>>      --------<br>
>>>      import wackyfunctionality;<br>
>>>      ...<br>
>>>      WackyFunction();<br>
>>>      --------<br>
>>>      module wackyfunctionality;<br>
>>><br>
>>>      void WackyFunction() {<br>
>>>          version (Linux)<br>
>>>            SomeWackyFunction();<br>
>>>          else version (OSX)<br>
>>>              SomeWackyFunction();<br>
>>>          else<br>
>>>              ... workaround ...<br>
>>>      }<br>
>>>      --------<br>
>><br>
>><br>
>><br>
>> Some years down the line (and some platform testing) turns into:<br>
>><br>
>> --------<br>
>> module wackyfunctionality;<br>
>><br>
>> void WackyFunction() {<br>
>>      version (Linux) {<br>
>>          version (ARM)<br>
>>              _SomeWackyFunction();<br>
>>          else version (MIPS)<br>
>>             MIPS_SomeWackyFunction();<br>
>>          else version (X86)<br>
>>             SomeWackyFunction();<br>
>>          else version (X86_64)<br>
>>             SomeWackyFunction();<br>
>>          else<br>
>>            ... should be some wacky function, but workaround for general case ...<br>
>>      }<br>
>>      else version (OSX) {<br>
>>          version (PPC)<br>
>>             iSomeWackyFunction();<br>
>>          else<br>
>>             SomeWackyFunction();   // In hope there's no other Apple hardware.<br>
>>      }<br>
>>      else version (OpenBSD) {<br>
>>        /// Blah<br>
>>      }<br>
>>      else version (Haiku) {<br>
>>        /// Blah<br>
>>      }<br>
>>      else<br>
>>          ... workaround ...<br>
>> }<br>
>> --------<br>
>><br>
><br>
><br>
> That is why the best approach is to have one module per platform specific code, with a common interface defined in .di file.<br>
></p>
<p dir="ltr">Don't tell me, tell the druntime maintainers.  :)<br>
</p>