September 20, 2017
On Wednesday, 20 September 2017 at 02:36:50 UTC, Jonathan M Davis wrote:
> On Wednesday, September 20, 2017 02:16:16 EntangledQuanta via Digitalmars-d- learn wrote:
>> On Tuesday, 19 September 2017 at 21:17:53 UTC, nkm1 wrote:
>> > On Tuesday, 19 September 2017 at 17:40:20 UTC, EntangledQuanta
>> >
>> > wrote:
>> >> [...]
>> >
>> > There are two issues there; operator precedence and booleans
>> > (_win[0] == '@') being a valid operands to +.
>> > If someone is too stupid to learn how precedence works, they
>> > should consider a different career instead of blaming others.
>> > OTOH, booleans converting to numbers is a very questionable
>> > feature. I certainly have never seen any good use for it. This
>> > is just an unfortunate legacy of C, which didn't even have
>> > booleans for a long time.
>>
>> Your an idiot, I know about how operator precedence works far more than you do. Wanna bet? how much? Your house? your wife? Your life? It's about doing things correctly, you seem to fail to understand, not your fault, can't expect a turd to understand logic.
>
> Please try to be civil. It's fine if you're unhappy about some aspect of how D works and want to discuss it, but we do not condone personal attacks here.
>
> - Jonathan M Davis


But, of course, It's ok for him to come me an idiot. Let me quote, not that it matters, since you are biased and a hypocrite:

">> > If someone is too stupid to learn how precedence works, they
>> > should consider a different career instead of blaming others."

But when I call him an idiot, I'm put in the corner.

I see how it works around here. What a cult!
September 20, 2017
On Wednesday, 20 September 2017 at 02:57:21 UTC, jmh530 wrote:
> On Wednesday, 20 September 2017 at 02:36:50 UTC, Jonathan M Davis wrote:
>>
>> Please try to be civil. It's fine if you're unhappy about some aspect of how D works and want to discuss it, but we do not condone personal attacks here.
>>
>> - Jonathan M Davis
>
> He seemed to be threatening the guy's life over operator precedence. Ridiculous...

Are you an idiot? Seriously, you must be. You just want to create drama instead of supply an actual logical argument(which I read your argument and it is pathetic). Show me where I threatened the guys life! Fucking moron. You must be some TSA goon or DHS wannabe.

September 20, 2017
On Wednesday, 20 September 2017 at 02:16:16 UTC, EntangledQuanta wrote:
> Your an idiot, I know about how operator precedence works far more than you do. Wanna bet? how much? Your house? your wife? Your life? It's about doing things correctly, you seem to fail to understand, not your fault, can't expect a turd to understand logic.

Ok, you win. I see now that you're very smart :)

September 20, 2017
On Tuesday, 19 September 2017 at 19:54:02 UTC, Steven Schveighoffer wrote:
> On 9/19/17 1:40 PM, EntangledQuanta wrote:
>
>> The first returns x + w/2 and the second returns w/2!
>
> Did you mean (x + w) / 2 or x + (w / 2)? Stop being ambiguous!
>
> -Steve

The best answer. :D
September 20, 2017
On Wednesday, 20 September 2017 at 02:34:50 UTC, EntangledQuanta wrote:
> When they then make up excuses to try to justify the wrong and turn it in to a right, they deserved to be attacked.

That isn't how it went down, you attacked then justification was provided.

> for someone that programs in about 20 different languages regularly, having logical consistency is important.

Could you imagine if D didn't allow you to learn how ternary is implemented? when you switched to one of those 19 other languages you'd expect it to work like D and make that catastrophic life threatening mistake you speak of.

But at last D followed logical consistency across languages so you can make the mistake once, learn, and apply it to all the other environments you're using.


> No, it doesn't logic is not based on circumstances, it's based on something that is completely independent of us... which is why it is called logic... because it is something we can all agree on regardless of our circumstances or environment... it is what math and hence all science is based on and is the only real thing that has made steady progress in the world. Illogic is what all the insanity is based on... what wars are from, and just about everything else, when you actually spend the time to think about it, which most people don't.

I will claim that it is illogical to make decisions ignoring environment and circumstances. For example, science heavily leverages environment (e.g. all objects fall at the same rate; environment: vacuum) (e.g. matter can neither be created nor destroyed; environment: not within a atomic explosion) (e.g. ...; environment: anything not quantum mechanics) (e.g. this satellite will follow this trajectory; environment: forces acting upon the satellite)

> Again, two wrongs don't make a right. What is the point of reimplementing C exactly as C is done?

I don't think there were any unjust or dishonest actions being done. Just an FYI the phrase isn't intended to be applied to all meanings of 'wrong'.

If you're a C(C++,C#,Java,...) programmer (environment) then when you are reading D code you will understanding the semantics and the semantics will remain the same if you copy code from your language into D.

> e.g., my attack is on the claims that D attempts to be *safe* and a *better C* and yet this(the ternary if) is just another instance of them contradicting themselves. Presenting something as safer when it is not gives the perception of safety and can actually be more dangerous than the original.

Safe to Walter has always been 'memory safe' but to you point of broader safety lets take my ()?: syntax and breaking backwards compatibility here is unsafe.

    q > a / (3 + 4) ? 0 : q;

This compiles today, it will also compile with the new syntax; the semantics would be completely different. This is a calculation running in production for a space shuttle to Mars. Before the launch they upgrade the compiler and this new calculation causes the shuttle to land in Florida off the coast of Minneapolis.

Backwards compatibility is important to safety just as following the majority. To ignore the environment you're working is illogical.
September 20, 2017
On 19.09.2017 23:17, nkm1 wrote:
> ...
> OTOH, booleans converting to numbers is a very questionable feature. > I certainly have never seen any good use for it. ...

Actually, it is useful enough to have a Wikipedia page:
https://en.wikipedia.org/wiki/Iverson_bracket

Example of a good use:

void floodFill(dchar[][] data,dchar c,int i,int j) {
    void dfs(int a, int b) {
        if (a<0 || a >= data.length) return;
        if (b<0 || b >= data[a].length) return;
        if (data[a][b] == c) return;
        data[a][b] = c;
        foreach(i; 0 .. 4){
            dfs(a + (i==0) - (i==1),
                b + (i==2) - (i==3));
        }
    }
    dfs(i, j);
}

unittest {
    import std.algorithm, std.conv, std.array;
    auto data = ["###.####...##"d,
                 "#....#...#..."d,
                 "..#....##.###"d,
                 "##...###...##"d,
                 "####...#....."d,
                 "#.#.#.#.#.#.#"d,
                 "#####.#######"d]
        .map!(to!(dchar[])).array;
    floodFill(data, '#', 1, 1);
    assert(data==["#############"d,
                  "#############"d,
                  "#########.###"d,
                  "########...##"d,
                  "########....."d,
                  "#.#.###.#.#.#"d,
                  "#############"d]);
}
September 20, 2017
On Wednesday, 20 September 2017 at 19:25:58 UTC, Timon Gehr wrote:
> On 19.09.2017 23:17, nkm1 wrote:
>> ...
>> OTOH, booleans converting to numbers is a very questionable feature. > I certainly have never seen any good use for it. ...
>
> Actually, it is useful enough to have a Wikipedia page:
> https://en.wikipedia.org/wiki/Iverson_bracket
> [snip]


While it's also possible to do this with filter, this is what I'd probably most often use it for.

import std.algorithm : sum;

void main()
{
    bool[] x = [true, false, true];
    int[] y = [1, 2, 3];
    y[] = x[] * y[];
    assert(sum(y[]) == 4);
}

It would be nice to be able to do:
assert(sum(x[] * y[]) == 4);
September 20, 2017
On Wednesday, 20 September 2017 at 19:25:58 UTC, Timon Gehr wrote:
> Actually, it is useful enough to have a Wikipedia page:
> https://en.wikipedia.org/wiki/Iverson_bracket

Mmmm... "The notation was originally introduced by Kenneth E. Iverson in his programming language APL".
APL... yeah :) Programmers didn't like it, did they. Anyway, that seems to be explicit notation, analogous to (cond ? 1 : 0).

> Example of a good use:
>
> void floodFill(dchar[][] data,dchar c,int i,int j) {
>     void dfs(int a, int b) {
>         if (a<0 || a >= data.length) return;
>         if (b<0 || b >= data[a].length) return;
>         if (data[a][b] == c) return;
>         data[a][b] = c;
>         foreach(i; 0 .. 4){
>             dfs(a + (i==0) - (i==1),
>                 b + (i==2) - (i==3));
>         }
>     }
>     dfs(i, j);
> }

I don't agree it's a good use. Actually, that seems quite obfuscated to me. Consider:
foreach (point; [[1, 0], [-1, 0], [0, 1], [0, -1]]) {
    dfs(a + point[0], b + point[1]);
}
Finds some random 10 programmers and ask them what's easier to understand...
Also, in my experience (in C and C++) it is extremely rare for programmers to use booleans in arithmetic. So even if in some situation you would have to replace this thing with more verbose (i == 0 ? 1 : 0), it's no big deal.
OTOH, booleans being numbers is a source of some bugs (just like other cases of weak typing). Not a ton of bugs, but the utility of implicit conversion to numbers is so unnoticeable that I'm sure it's just not worth it.
September 20, 2017
A general rule of thumb when it comes to operator precedence is that when in doubt, add parenthesis.

On Wednesday, 20 September 2017 at 02:16:16 UTC, EntangledQuanta wrote:
> Your an idiot,
> Your

Huh.
September 20, 2017
On Wednesday, September 20, 2017 21:13:58 nkm1 via Digitalmars-d-learn wrote:
> OTOH, booleans being numbers is a source of some bugs (just like other cases of weak typing). Not a ton of bugs, but the utility of implicit conversion to numbers is so unnoticeable that I'm sure it's just not worth it.

I think that most of us would agree with you, but the last time it was serious discussed, Walter couldn't be convinced. Based on more recent discussions with him, he did seem to now agree that we're probably too liberal with how many implicit conversions we allow, but I don't know which ones specifically he'd be willing to do differently if we didn't care about breaking code. But since breaking code would definitely be a problem with any implicit conversion that was removed, I doubt that it would be easy to talk him into making any changes to the implicit conversions now even if you could get him to agree that we ideally would.

- Jonathan M Davis