C++ UFCS update
Era Scarecrow via Digitalmars-d
digitalmars-d at puremagic.com
Tue Feb 23 12:54:25 PST 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).
More information about the Digitalmars-d
mailing list