Thread overview | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
June 13, 2015 version: multiple conditions | ||||
---|---|---|---|---|
| ||||
What is the rationale for not allowing multiple version conditions? Example: version(iOS || Android) { pthread_create(...) } else version(Win32) { CreateThread(...) } I wasn't able to find the conversations on this. I heard rumors in DLearn that Walter was against this, but I'm wondering if the sentiment has changed at this point. Is there is any wiggle room for at least adding "||" so that code can be shared between platforms? This is trivial to do in C, C++, and even C#: #if OS_IOS || OS_ANDROID ... #elif OS_WINDOWS #endif In Rust, there is attributes for this: #[cfg(any(not(unix), all(target_os="macos", target_arch = "powerpc")))] void something() { } I haven't yet seen a solution in D that justifies not having this feature. Thanks, Bit |
June 13, 2015 Re: version: multiple conditions | ||||
---|---|---|---|---|
| ||||
Posted in reply to bitwise | On Saturday, 13 June 2015 at 20:57:14 UTC, bitwise wrote:
> What is the rationale for not allowing multiple version conditions?
>
> Example:
>
> version(iOS || Android) {
> pthread_create(...)
> }
> else version(Win32) {
> CreateThread(...)
> }
>
> I wasn't able to find the conversations on this.
>
> I heard rumors in DLearn that Walter was against this, but I'm wondering if the sentiment has changed at this point. Is there is any wiggle room for at least adding "||" so that code can be shared between platforms?
>
>
> This is trivial to do in C, C++, and even C#:
>
> #if OS_IOS || OS_ANDROID
> ...
> #elif OS_WINDOWS
>
> #endif
>
>
> In Rust, there is attributes for this:
>
> #[cfg(any(not(unix), all(target_os="macos", target_arch = "powerpc")))]
> void something() {
>
> }
>
> I haven't yet seen a solution in D that justifies not having this feature.
>
>
> Thanks,
> Bit
iirc this falls under the "walter dislikes it so we won't have it" category.
|
June 13, 2015 Re: version: multiple conditions | ||||
---|---|---|---|---|
| ||||
Posted in reply to weaselcat | On Sat, 13 Jun 2015 17:16:04 -0400, weaselcat <weaselcat@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
|
June 13, 2015 Re: version: multiple conditions | ||||
---|---|---|---|---|
| ||||
Posted in reply to bitwise | On Saturday, 13 June 2015 at 21:19:28 UTC, bitwise wrote:
> On Sat, 13 Jun 2015 17:16:04 -0400, weaselcat <weaselcat@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.
|
June 13, 2015 Re: version: multiple conditions | ||||
---|---|---|---|---|
| ||||
Posted in reply to Xiaoxi | On Sat, 13 Jun 2015 17:29:17 -0400, Xiaoxi <xiaoxi@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@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;
}
else version (FreeBSD) {
import core.sys.freebsd.dlfcn;
}
version(linux || FreeBSD) {
dlopen(...)
}
I shouldn't have to add another version just for that last dlopen block. It's not "finegrained" control, it's cruft.
Bit
|
June 14, 2015 Re: version: multiple conditions | ||||
---|---|---|---|---|
| ||||
Posted in reply to bitwise | On 6/13/15 4:57 PM, bitwise wrote:
> What is the rationale for not allowing multiple version conditions?
>
> Example:
>
> version(iOS || Android) {
> pthread_create(...)
> }
> else version(Win32) {
> CreateThread(...)
> }
>
> I wasn't able to find the conversations on this.
>
> I heard rumors in DLearn that Walter was against this, but I'm wondering
> if the sentiment has changed at this point. Is there is any wiggle room
> for at least adding "||" so that code can be shared between platforms?
No, it hasn't changed. Walter will not accept this, I don't think there's any hope for it.
Just use the static if trick.
-Steve
|
June 14, 2015 Re: version: multiple conditions | ||||
---|---|---|---|---|
| ||||
Posted in reply to bitwise | On Saturday, 13 June 2015 at 21:51:43 UTC, bitwise wrote: > I shouldn't have to add another version just for that last dlopen block. It's not "finegrained" control, it's cruft. > > Bit It works with constants definition files. https://github.com/etcimon/botan/blob/master/source/botan/constants.d The mono-d IDE doesn't always like it but it's the best I've got. |
June 14, 2015 Re: version: multiple conditions | ||||
---|---|---|---|---|
| ||||
Posted in reply to bitwise | On Saturday, 13 June 2015 at 21:51:43 UTC, bitwise wrote: > On Sat, 13 Jun 2015 17:29:17 -0400, Xiaoxi <xiaoxi@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@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. |
June 14, 2015 Re: version: multiple conditions | ||||
---|---|---|---|---|
| ||||
Posted in reply to Joakim Attachments: | On Sun, 14 Jun 2015 10:35:30 +0000, Joakim wrote:
> 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.
honestly, if i'll want to have a limited language, i'll take Go. removing a power only 'cause it can be abused is not in a "spirit of D", at least as i see it. templates can be enormously abused, but noone claims that they should be removed, as code without templates sometimes easier to follow, and abusing templates can be a PITA.
|
June 14, 2015 Re: version: multiple conditions | ||||
---|---|---|---|---|
| ||||
Posted in reply to Joakim Attachments: | p.s. i.e. it boils down to simple thing: Walter don't like it. period. any rationalizing of that is pointless. |
Copyright © 1999-2021 by the D Language Foundation