3 ms·
It also took the C++ community about 10 years to realize that the way iostreams was doing operator overloading to do pipelining was an abomination as well. In
by WalterBright 4y ago
It also took the C++ community about 10 years to realize that the way iostreams was doing operator overloading to do pipelining was an abomination as well.
In the D community, we also strongly discourage operator overloading for any purpose other than creating arithmetic types.
- tialaramex 4y agoI am doubtful that even WG21 as originally constituted would have accepted I/O Streams with its "Look at me, I've got operator overloading" operator abuse if it wasn't Stroustrup's own code. If some outsider had come along and said "Look at this slower, clumsier, operator abusing alternative to C's stdio" the committee might have quoted Stroustrups' own words condemning such abuse. "the ability to define new meanings for old operators can be used to write programs that are well nigh incomprehensible". I'm with you up to a point on overloading, if it were up to me for example Rust would not implement Add and AddAssign on String, and certainly Java wouldn't special case += but we are where we are. However Rust has several operators (fewer than C++ but still several) that aren't just for arithmetic types. Deref and DerefMut of course (used to implement smart pointers such as Arc), Index and IndexMut (for the indexing operator []) but also Try (implementation of the ? operator) and (though rather more distant into your future than Try if you write Stable Rust) the Function operator traits Fn, FnMut and FnOnce which represent callables. Of course arguably Rust isn't overloading operators at all. Rust has no subtyping, and so whether you can Add or Multiply or Try something is a matter only of whether that type implements the associated Trait.
- pjmlp 4y agoNot everyone shares that point of view. Gladly using iostreams since 1993.
- WalterBright 4y agoFortunately, I said "community" not "everyone"!
- pjmlp 4y agohttps://www.merriam-webster.com/dictionary/community https://www.merriam-webster.com/dictionary/community Unless you define "community" as those that do not share your point of view.
- WalterBright 4y agoSorry, "everyone" is your strawman.
- pjmlp 4y agoWhatever fits your concept of community.