"version" private word
Igor Shirkalin
mathsoft at inbox.ru
Tue Oct 31 15:46:36 UTC 2017
On Tuesday, 31 October 2017 at 15:19:49 UTC, Steven Schveighoffer
wrote:
> On 10/31/17 10:47 AM, Igor Shirkalin wrote:
>>>> [...]
>>>
>>> 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 :)
Ah. :)
>
>> 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.
Now I understand the irritation about my question. I'm sorry.
>
> 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).
This doesn't solve the case with combinations of different
versions. Four different versions produce nine (+4) different
variants. It's stupid to define 9 additional version constants.
>
> 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.
Yes, it's now clear for me what to do. Thanks!
More information about the Digitalmars-d-learn
mailing list