Good examples of version() algebra in real code
Steven Schveighoffer
schveiguy at gmail.com
Mon May 22 12:41:24 UTC 2023
On 5/21/23 3:09 PM, Guillaume Piolat wrote:
> On Sunday, 21 May 2023 at 18:43:32 UTC, Dennis wrote:
>>
>> - have real problems with existing `version()` statements (besides 'it
>> looks ugly')
>>
>
>
> No big problem, but sometimes you need to do:
>
> version(X86)
> version = AnyX86;
> version(X86_64)
> version = AnyX86;
>
> or
>
> version (OSX)
> version = Darwin;
> else version (iOS)
> version = Darwin;
> else version (TVOS)
> version = Darwin;
> else version (WatchOS)
> version = Darwin;
>
> or
>
> version (D_InlineAsm_X86)
> version = UseX86Assembly;
> version (D_InlineAsm_X86_64)
> version = UseX86Assembly;
>
> and those are the only case I remember being a tiny bit annoyed at
> `version`. I wouldn't use the above library solution to save one import.
>
One of the largest problems with this scheme is it needs to be repeated
in every module that uses e.g. `version(Darwin)`.
-Steve
More information about the Digitalmars-d
mailing list