version: multiple conditions
Joakim via Digitalmars-d
digitalmars-d at puremagic.com
Sun Jun 14 03:35:30 PDT 2015
On Saturday, 13 June 2015 at 21:51:43 UTC, bitwise wrote:
> On Sat, 13 Jun 2015 17:29:17 -0400, Xiaoxi <xiaoxi at 163.com>
> wrote:
>
>> On Saturday, 13 June 2015 at 21:19:28 UTC, bitwise wrote:
>>> On Sat, 13 Jun 2015 17:16:04 -0400, weaselcat
>>> <weaselcat at gmail.com> wrote:>
>>>> iirc this falls under the "walter dislikes it so we won't
>>>> have it" category.
>>>
>>> As Andrei said at DConf though, consensus requires at least 3
>>> people ;)
>>>
>>> Bit
>>
>> The current design encourages using more finegrained features
>> instead of the more blunt Os level versions.
>>
>> version(iOS) { version = pthread;}
>> version(Android) { version = pthread;}
>>
>> In the rest of the file simply check for pthread instead of OS.
>
>
> That _sounds_ nice, but consider this:
>
> version (linux) {
> import core.sys.linux.dlfcn;
version = use_dlopen;
> }
> else version (FreeBSD) {
> import core.sys.freebsd.dlfcn;
version = use_dlopen;
> }
>
> version(linux || FreeBSD) {
//version(linux || FreeBSD) {
version(use_dlopen) {
> dlopen(...)
> }
>
> I shouldn't have to add another version just for that last
> dlopen block. It's not "finegrained" control, it's cruft.
It does require more definitions, but it's worth it. A simple
example like yours may seem excusable, but there's no way to
limit such logic to just simple instances. Walter is coming from
long experience with this, and even with my limited experience
with such logic, I'm grateful for it, as dealing with more
complex versions of such logic is a royal PITA.
More information about the Digitalmars-d
mailing list