C++ UFCS update

Ola Fosheim Grøstad via Digitalmars-d digitalmars-d at puremagic.com
Tue Feb 23 12:35:16 PST 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.



More information about the Digitalmars-d mailing list