Jump to page: 1 212  
Page
Thread overview
version: multiple conditions
Jun 13, 2015
bitwise
Jun 13, 2015
weaselcat
Jun 13, 2015
bitwise
Jun 13, 2015
Xiaoxi
Jun 13, 2015
bitwise
Jun 14, 2015
Etienne Cimon
Jun 14, 2015
Joakim
Jun 14, 2015
ketmar
Jun 14, 2015
Joakim
Jun 14, 2015
ketmar
Jun 14, 2015
bitwise
Jun 16, 2015
Walter Bright
Jun 16, 2015
Dennis Ritchie
Jun 16, 2015
Dennis Ritchie
Jun 16, 2015
Jacob Carlborg
Jun 16, 2015
Jonathan M Davis
Jun 16, 2015
rsw0x
Jun 16, 2015
Walter Bright
Jun 16, 2015
rsw0x
Jun 16, 2015
rsw0x
Jun 16, 2015
anonymous
Jun 16, 2015
bitwise
Jun 17, 2015
Jacob Carlborg
Jun 16, 2015
Walter Bright
Jun 17, 2015
Jonathan M Davis
Jun 17, 2015
Jacob Carlborg
Jun 18, 2015
Jacob Carlborg
Jun 17, 2015
Jonathan M Davis
Jun 17, 2015
Timon Gehr
Jun 17, 2015
ketmar
Jun 17, 2015
weaselcat
Jun 17, 2015
ketmar
Jun 14, 2015
ketmar
Jun 14, 2015
Paulo Pinto
Jun 14, 2015
weaselcat
Jun 14, 2015
ketmar
Jun 14, 2015
ketmar
Jun 14, 2015
ketmar
Jun 15, 2015
Jonathan M Davis
Jun 15, 2015
John Colvin
Jun 15, 2015
bitwise
Jun 16, 2015
Walter Bright
Jun 17, 2015
Daniel Murphy
Jun 17, 2015
Walter Bright
Jun 17, 2015
ketmar
Jun 18, 2015
ketmar
Jun 18, 2015
ketmar
Jun 26, 2015
Daniel Murphy
Jun 28, 2015
Joakim
Jun 28, 2015
Artur Skawina
Jun 28, 2015
Joakim
Jul 04, 2015
Artur Skawina
Jul 04, 2015
Joakim
Jul 04, 2015
Walter Bright
Jul 05, 2015
Jonathan M Davis
Jun 28, 2015
Walter Bright
Jun 29, 2015
bitwise
Jun 30, 2015
Walter Bright
Jun 30, 2015
bitwise
Jun 30, 2015
rsw0x
Jun 30, 2015
bitwise
Jun 30, 2015
Jonathan M Davis
Jun 30, 2015
Joakim
Jul 02, 2015
Walter Bright
Jul 01, 2015
ketmar
Jul 01, 2015
ketmar
Jul 01, 2015
Jonathan M Davis
Jul 01, 2015
rsw0x
Jul 01, 2015
ketmar
Jul 02, 2015
David Nadlinger
Jul 02, 2015
ketmar
Jul 02, 2015
ketmar
Jul 02, 2015
ketmar
Jul 02, 2015
ketmar
Jul 03, 2015
ketmar
Jul 02, 2015
bitwise
Jul 02, 2015
ketmar
Jul 02, 2015
Jonathan M Davis
Jul 02, 2015
ketmar
Jun 14, 2015
bitwise
Jun 16, 2015
Walter Bright
Jun 16, 2015
David Nadlinger
Jun 16, 2015
Walter Bright
Jun 16, 2015
Joakim
Jun 14, 2015
Manfred Nowak
Jun 14, 2015
bitwise
Jun 16, 2015
Walter Bright
Jun 17, 2015
Daniel Murphy
Jun 17, 2015
Walter Bright
Jun 15, 2015
Mike Parker
Jun 15, 2015
ketmar
Jul 01, 2015
anonymous
Jun 15, 2015
ketmar
Jun 15, 2015
ketmar
Jun 17, 2015
ketmar
Jun 18, 2015
ketmar
Jun 18, 2015
Timon Gehr
Jun 19, 2015
ketmar
June 13, 2015
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
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
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
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
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
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
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
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
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
p.s. i.e. it boils down to simple thing: Walter don't like it. period. any rationalizing of that is pointless.

« First   ‹ Prev
1 2 3 4 5 6 7 8 9 10 11