May 11, 2016
On 5/11/2016 10:02 AM, bitwise wrote:
> When even D gurus writing D compilers have to hack solutions together with
> static if to get by,

Really? There are a few lines of that left in dmd, but as a result of mechanical conversion from C++. There's other C++ cruft in there, too.


> its time to re-evaluate the situation.

Actually, dmd is a nice example of how unnecessary it is. The dmd C++ source code used to be full of it.

May 11, 2016
On Wednesday, 11 May 2016 at 20:37:35 UTC, Walter Bright wrote:
> Actually, dmd is a nice example of how unnecessary it is. The dmd C++ source code used to be full of it.

I'm convinced that you're argument is reasonable if version is only for things like platforms, but it's used for a lot of other stuff e.g. version(PrintSomeExtraInfo) or version(CacheSomeStuffForPerformance). Do you think the same principle applies there?
May 11, 2016
On 5/11/2016 1:42 PM, John Colvin wrote:
> I'm convinced that you're argument is reasonable if version is only for things
> like platforms, but it's used for a lot of other stuff e.g.
> version(PrintSomeExtraInfo) or version(CacheSomeStuffForPerformance). Do you
> think the same principle applies there?

Yes, I do.

  https://github.com/dlang/dmd/pull/5767

I've also seen very good programmers find 'absolutely must have' uses for static if, used them, and caused bugs due to the tangled up nature of it. I had to go in and fix it.

It takes a while to change one's thinking from the C++ #if expressions, but the result is worth it.
May 12, 2016
On Tuesday, 10 May 2016 at 14:47:05 UTC, Tomer Filiba wrote:
> On Tuesday, 10 May 2016 at 12:27:19 UTC, Johan Engelen wrote:
>> We resort to enums whenever 'version' is not adequate like this:
>> https://github.com/ldc-developers/ldc/blob/master/ddmd/globals.d#L18-L45
>
> A good example -- which only proves how the current version() block is insufficient. So instead of version(xxx), which states your intent clearly, you get lots of non-idiomatic static ifs, which are more cumbersome and error prone.

That example is misleading, as that was translated from C++ and the host half of it was removed a couple months ago:

https://github.com/dlang/dmd/pull/5549/files

I'll submit a PR for the rest: I'm sick of this argument that "ddmd is using static if, so why shouldn't I?"
May 11, 2016
On 5/11/2016 6:52 PM, Joakim wrote:
> That example is misleading, as that was translated from C++ and the host half of
> it was removed a couple months ago:
>
> https://github.com/dlang/dmd/pull/5549/files
>
> I'll submit a PR for the rest: I'm sick of this argument that "ddmd is using
> static if, so why shouldn't I?"

Please do. That code is an abomination.
May 13, 2016
On Thursday, 12 May 2016 at 01:58:33 UTC, Walter Bright wrote:
> On 5/11/2016 6:52 PM, Joakim wrote:
>> That example is misleading, as that was translated from C++ and the host half of
>> it was removed a couple months ago:
>>
>> https://github.com/dlang/dmd/pull/5549/files
>>
>> I'll submit a PR for the rest: I'm sick of this argument that "ddmd is using
>> static if, so why shouldn't I?"
>
> Please do. That code is an abomination.

I'm trying, but Daniel seems against it, care to chip in?

https://github.com/dlang/dmd/pull/5772

Specifically, do you want the changes in that PR?  If so, do you prefer the use of TARGET_POSIX as a runtime variable or listing each TARGET_OS separately?
May 13, 2016
On 5/13/2016 1:57 AM, Joakim wrote:
> I'm trying, but Daniel seems against it, care to chip in?
>
> https://github.com/dlang/dmd/pull/5772
>
> Specifically, do you want the changes in that PR?  If so, do you prefer the use
> of TARGET_POSIX as a runtime variable or listing each TARGET_OS separately?

I know there's some controversy in that thread, I guess I need to check in.
December 14, 2018
On Wednesday, 11 May 2016 at 17:02:36 UTC, bitwise wrote:
> On Tuesday, 10 May 2016 at 11:12:58 UTC, Tomer Filiba wrote:
>> Hey guys,
>>
>> Looking at our code base (weka), I realized it would be really useful if we had logical operators (negation, conjunction, disjunction) in the version's "condition" clause. Here's what I have in mind:
>>
>> version(!extra_checks) {
>>     ...
>> }
>>
>> version(dlang_ver_2069 || dlang_ver_2070) {
>>     ...
>> }
>>
>> Today we have lots of ugly code like
>>
>> version(unittest) {} else { ... }
>>
>> and bad-old copy-paste for the logical-or case I mentioned.
>>
>> Is there any reason for that versions can't take compound logical conditions? Alternatively, an isVersion(x) predicate that I could use in a static if could do the trick -- although I think ``version(x || y)`` is more readable than ``static if (isVersion(x) || isVersion(y))``
>>
>> I think it could be a useful feature. Any thoughts?
>>
>> -tomer
>
> Still holding out hope Walter will change his mind here..
>
> His rationale is based on keeping code clean and organized, but given that D has no preprocessor macros, it will never look as bad as C++ code, or even close.
>
> Compounding versions in C++ accounts for a very small portion of the mess. When you have an #if VERS every 5 lines, however, you've got a problem...but then, you can do that with D's version just the same. The real solution is to properly encapsulate system-dependant code so that whatever version statement you need, is all in one place. Also when you have to hack 10 different macros together to invent a feature your language doesn't have, you've got a problem, but this is much less of a concern in D than C++.
>
> When even D gurus writing D compilers have to hack solutions together with static if to get by, its time to re-evaluate the situation.
>
>    Bit

Most things aside from straight up

version([!]condition [op condition... [op condition...]) { ... } [else { ... }]

are going to lead to surprising behavior, bad code, and gnashing of teeth. We shouldn't have to resort to macros to do this.
December 13, 2018
On Thursday, December 13, 2018 5:45:10 PM MST Andrew Pennebaker via Digitalmars-d wrote:
> On Wednesday, 11 May 2016 at 17:02:36 UTC, bitwise wrote:
> > Still holding out hope Walter will change his mind here..
> >
> > His rationale is based on keeping code clean and organized, but given that D has no preprocessor macros, it will never look as bad as C++ code, or even close.
> >
> > Compounding versions in C++ accounts for a very small portion of the mess. When you have an #if VERS every 5 lines, however, you've got a problem...but then, you can do that with D's version just the same. The real solution is to properly encapsulate system-dependant code so that whatever version statement you need, is all in one place. Also when you have to hack 10 different macros together to invent a feature your language doesn't have, you've got a problem, but this is much less of a concern in D than C++.
> >
> > When even D gurus writing D compilers have to hack solutions together with static if to get by, its time to re-evaluate the situation.
> >
> >    Bit
>
> Most things aside from straight up
>
> version([!]condition [op condition... [op condition...]) { ... }
> [else { ... }]
>
> are going to lead to surprising behavior, bad code, and gnashing of teeth. We shouldn't have to resort to macros to do this.

You might want to pay attention to the date of the post that you're replying to. It's about two-and-a-half years old.

- Jonathan M Davis



1 2
Next ›   Last »