February 23, 2016
On Tuesday, 23 February 2016 at 20:11:01 UTC, Era Scarecrow wrote:
>  c->x and c.x were basically the same. Why not use -> instead of | ?

Sure, you can do that. Other languages use "->" for pushing parameters.

But in C/C++ "x->m" is a shorthand for "(*x).f".

C++ also have "and" and "or" as a shorthand for "&&" and "||", btw. I think "and" and "or" often makes code look more readable, yet I've never seen them used.

> Honestly looking at them side by side, I don't like |, -> is almost preferable except I sometimes don't hit the > and have to re-edit it, unlike using ., but that's a minor gripe there.

Yes, I also like arrows for suggesting the direction when you have pipelines.

>  Hell why not extend to the rest of the operators? Don't forget C++'s iostream pushes using very specific low level operations to do weird things.

The primary issue I have with iostream is that floating point formatting gets ugly. The "<<" works out ok for iostream in practice, mostly because it is not common to do bit-shifts in combination with IO.

And I have to say that I find it ironic that Walter objects to reusing operators such as "<<" while he is reusing "!" for templates, which I find waaay more annoying than iostream.

February 23, 2016
On 23.02.2016 21:35, Ola Fosheim Grøstad wrote:
> I find it ironic that Walter objects to reusing operators such as "<<"
> while he is reusing "!" for templates

No reusing and no irony here. "!" for template instantiation is a binary usage.
February 23, 2016
On Tuesday, 23 February 2016 at 20:35:16 UTC, Ola Fosheim Grøstad wrote:
> But in C/C++ "x->m" is a shorthand for "(*x).f".

 I remember many compiling errors were I'd have to switch . with -> and vice versa... I don't really want to return to that, especially when you have two versions of compilers.

> C++ also have "and" and "or" as a shorthand for "&&" and "||", btw. I think "and" and "or" often makes code look more readable, yet I've never seen them used.

 Considering it's just an #include forcing a replacement, it hides a little of what it's doing. Honestly && and || look fine to me. More confusing if they are 3 levels deep and lots of them, but 2-4 of them are easy to glance at and get the idea what's going on.

> Yes, I also like arrows for suggesting the direction when you have pipelines.

 But they only ever go one way... left to right.

> The primary issue I have with iostream is that floating point formatting gets ugly. The "<<" works out ok for iostream in practice, mostly because it is not common to do bit-shifts in combination with IO.

 I'd argue that, but I don't really have the experience to show an example. C and C++ were both very close to the hardware, every symbol and feature is almost a 1:1 representation of the machine code/intent, then compiled to work on that specific machine: + is add, - is sub, ~ is neg, etc etc. That's another reason -> was used because the indirection could make a noticeable difference in heavy code (especially if they were several levels deep).

> And I have to say that I find it ironic that Walter objects to reusing operators such as "<<" while he is reusing "!" for templates, which I find waaay more annoying than iostream.

 So you're annoyed that Walter uses ! which is used 1/500th the time compared to << and >>, and by using ! he avoided the annoying <> which causes lots of slowdowns during compiling while doing templates. One of the best reasons ! works is it's an unary operation, compared to << >> < and >. He also reused ~ for appending (previously neg) also used about 1/500th of the time, but you aren't complaining about that (unless I just haven't noticed since I'm not watching the forums closely).
February 23, 2016
On Tuesday, 23 February 2016 at 20:54:25 UTC, Era Scarecrow wrote:
>  Considering it's just an #include forcing a replacement, it hides a little of what it's doing. Honestly && and || look fine

No, they are keywords.

http://en.cppreference.com/w/cpp/keyword/and

> machine: + is add, - is sub, ~ is neg, etc etc. That's another reason -> was used because the indirection could make a noticeable difference in heavy code (especially if they were several levels deep).

Huh? C is a minimalistic language, where even basic operations are just syntactical sugar. E.g. "a[2+3]" is just a short hand for "*(a+2+3)".

>  So you're annoyed that Walter uses ! which is used 1/500th the time compared to << and >>, and by using ! he avoided the annoying <> which causes lots of slowdowns during compiling while doing templates.

No way "!" is less used than "<<"... And "<...>" does not cause noticable slow downs when compiling.

> One of the best reasons ! works is it's an unary operation, compared to << >> < and >. He also reused ~ for appending (previously neg) also used about 1/500th of the time,

Another horrible idea.

> but you aren't complaining about that (unless I just haven't noticed since I'm not watching the forums closely).

Oh yes, I have. :-)


February 23, 2016
On 2/23/2016 12:35 PM, Ola Fosheim Grøstad wrote:
> And I have to say that I find it ironic that Walter objects to reusing operators
> such as "<<" while he is reusing "!" for templates,

Hardly. ! is not an overloadable operator in D, and ! has no binary operator meaning other than for template argument lists. I.e. it is not "reuse" at all.

Furthermore, iostreams' use of << is neither thread-safe nor exception-safe, though its designer could be forgiven because iostreams predates both concepts. The only interesting thing about iostreams is why it wasn't deprecated 20 years ago, despite being ugly, not thread-safe, not exception-safe, and slow.

February 24, 2016
On Wednesday, 24 February 2016 at 07:19:02 UTC, Walter Bright wrote:
> On 2/23/2016 12:35 PM, Ola Fosheim Grøstad wrote:
>> And I have to say that I find it ironic that Walter objects to reusing operators
>> such as "<<" while he is reusing "!" for templates,
>
> Hardly. ! is not an overloadable operator in D, and ! has no binary operator meaning other than for template argument lists. I.e. it is not "reuse" at all.
>
> Furthermore, iostreams' use of << is neither thread-safe nor exception-safe, though its designer could be forgiven because iostreams predates both concepts. The only interesting thing about iostreams is why it wasn't deprecated 20 years ago, despite being ugly, not thread-safe, not exception-safe, and slow.

Could you add to D operators like AND OR etc instead of && ||. Words are more readable.
February 24, 2016
On Tuesday, 23 February 2016 at 20:35:16 UTC, Ola Fosheim Grøstad wrote:
> The primary issue I have with iostream is that floating point formatting gets ugly. The "<<" works out ok for iostream in practice, mostly because it is not common to do bit-shifts in combination with IO.

stdout << "double value is: " << i<<1;

Oops.
This happens, and you won't notice until someone complains about the wrong value in the output.

in D neither ! nor ~ is "reused". They are both unary operators in C. D only defined new binary operators which use the same characters, but there is no way to confuse them.

On the other side having two different "piplining" operators "." and "->" makes refactoring the code an ugly mess: If you decided to use a reference parameter instead of a pointer you have to replace all "->" by ".". But oops, there is still a pointer within the referenced struct? So, don't replace them all, but carefully revisit them to check where "." is necessary and where "->".
I always hated that!
February 23, 2016
On 2/23/2016 11:23 PM, Suliman wrote:
> Could you add to D operators like AND OR etc instead of && ||. Words are more
> readable.

Those exist in C++ and I've never seen them used outside of a test suite. That's not encouraging.
February 24, 2016
On Wednesday, 24 February 2016 at 07:23:03 UTC, Suliman wrote:
> On Wednesday, 24 February 2016 at 07:19:02 UTC, Walter Bright wrote:
>> On 2/23/2016 12:35 PM, Ola Fosheim Grøstad wrote:
>>> [...]
>>
>> Hardly. ! is not an overloadable operator in D, and ! has no binary operator meaning other than for template argument lists. I.e. it is not "reuse" at all.
>>
>> Furthermore, iostreams' use of << is neither thread-safe nor exception-safe, though its designer could be forgiven because iostreams predates both concepts. The only interesting thing about iostreams is why it wasn't deprecated 20 years ago, despite being ugly, not thread-safe, not exception-safe, and slow.
>
> Could you add to D operators like AND OR etc instead of && ||. Words are more readable.

It's a matter of taste I think.
I find 'and's and 'or's less readable than && and ||.

I suspect that's because I'm used to looking at them.
February 24, 2016
On Wednesday, 24 February 2016 at 07:25:13 UTC, Dominikus Dittes Scherkl wrote:
> stdout << "double value is: " << i<<1;
>
> Oops.

error: invalid operands of types '_IO_FILE*' and 'const char [18]' to binary 'operator<<'

> This happens, and you won't notice until someone complains about the wrong value in the output.

Only a neophyte would make such a mistake. Thanks to the messy precedence for operators in C you always have to be careful with parentheses.

> in D neither ! nor ~ is "reused". They are both unary operators in C. D only defined new binary operators which use the same characters, but there is no way to confuse them.

I am used to D-advocates blindly defending any position, but claiming that symbols aren't reused in D isn't a position I would expect anyone to defend. Unary or binary is not the issue.

if(!a!(c,!d)(!e)){...}
a~=3;
b=~3;

> On the other side having two different "piplining" operators "." and "->" makes refactoring the code an ugly mess: If you decided to use a reference parameter instead of a pointer you have to replace all "->" by ".". But oops, there is still a pointer within the referenced struct?

In C++ I typically use "&" or "&&" references instead of pointers. In D's "Unique" you get weak duck-typing where you risk accessing a member of Unique instead of the object.

However for C++ smart pointers you generally use "->" so you get strong typing.