"version" private word

Steven Schveighoffer schveiguy at yahoo.com
Tue Oct 31 15:19:49 UTC 2017


On 10/31/17 10:47 AM, Igor Shirkalin wrote:
> On Tuesday, 31 October 2017 at 14:31:17 UTC, Jesse Phillips wrote:
>> On Tuesday, 31 October 2017 at 14:25:19 UTC, Igor Shirkalin wrote:
>>> On Tuesday, 31 October 2017 at 14:22:37 UTC, Jesse Phillips wrote:
>>>> On Tuesday, 31 October 2017 at 13:46:40 UTC, Igor Shirkalin wrote:
>>>>> Hello!
>>>>>
>>>>
>>>> You goal should be to describe features.
>>>>
>>>> Version x86
>>>> ... Version = I can stand on my head
>>>> ...
>>>
>>> pardon?
>>
>> Sorry I hate writing code on mobile.
>>
>> You can create an arbitrary version by assigning a symbol to it, use 
>> that symbol to describe a feature, assign that symbol for each 
>> architecture that supports it. Then write code in a version block of 
>> that symbol.
> 
> The question was not about mobile platforms.

I think he meant he didn't like writing code in a forum post on his 
mobile, so he wrote something more abstract :)

> Sometimes we need to mix 
> some combinations of code in one big project with or without some 
> libraries, algorithms etc.
> I see what you mean and practically agree with you. But not everything 
> depends on you (us).

The above response has been the standard D answer for as long as this 
question has been asked (and it has been asked a lot). Walter is 
dead-set against allowing boolean expressions in version statements.

The anointed way is to divide your code by feature support, and then 
version those features in/out based on the platform you are on.

For example, instead of "X86_or_X64", you would do "TryUsingSSE" or 
something (not sure what your specific use case is).

However, enums and static if can be far more powerful. Version 
statements do not extend across modules, so you may have to repeat the 
entire scaffolding to establish versions in multiple modules. Enums are 
accessible across modules.

-Steve


More information about the Digitalmars-d-learn mailing list