Alf P. Steinbach wrote:
> On 04.04.2020 06:58, Ned Latham wrote:
> > James Kuyper wrote:
> > > Ned Latham wrote:
> > > > Jorgen Grahn wrote:
> > > > > Ned Latham wrote:
> > > > > ...
> > > > > > C++ has become a moving target and a profligate producer of
> > > > > > maintenance nightmares. My own projects are okay so far, but
> > > > > > I've had to make so many fatuous changes that I'm now actively
> > > > > > looking for languages to port them to.
> > > > >
> > > > > Which changes would that be? Between, say a decent version two
> > > > > decades ago (C++98) and a well-supported one today (C++11)?
> > > >
> > > > Exception throwing: once an option, now the default.
> > > > "namespace": once an option, now a requirement.
> > >
> > > Could you identify the specific changes in the text of the standard that
> > > you're referring to, and when they happened?
> >
> > No. I don't geek around with committee standards. The only C++ standard
> > that I know is Stroustrup's: "Programming in C++", vol 3, 1997.
>
> At that time, close up to the first standardization in 1998, the /de
> facto/ standard was the Annotated Reference Manual, the "ARM", by Bjarne
> Stroustrup and Margaret Ellis, IIRC.
Sounds familiar, though I don't have it.
> > Exception throwing was optional back then
>
> The standard exception hierarchy wasn't finished until close up to
> standardization, I believe about the time of that book, anyway after
> 1995.
>
> As I recall Microsoft's Visual C++ didn't implement the new hierarchy
> until some years after the standardization, I believe in Visual
> Studio.NET in 2003 or so.
'Sfunny. I've been toying with the notion of developing a language
that gives the programmer complete control of all elements of code
generation, and one of the thoughts was that it might be a good
idea to put a minimal version it out there and get help enhancing it.
C++ shows pretty clearly that it's a bad idea. (Well, if it's done by
committee.)
----snip----
> 1990's tools and techniques are fine, just fine, just not as convenient
> as modern approach. Stick with what you know.
That's one option. Another is a stable language, with context-sensitive
error control.
> However, you'll have to
> adjust some details because compilers now generally conform to the ISO
> standard and not the ARM,
I will not be doing that. Next time I hit a version that wants me to
alter my code, I'll dump it. Either downgrade or switch.
> e.g. about lifetime of temporaries.
I always regard those as lasting until their return.
With the declarations
# include <mclib.h> // The library I referred to earlier.
and
StringC one("I'm "), two("outta here.");
the command
(one + two).Write(stderr);
puts "I'm outta here." on the error stream.
And it (the temporary) really is.
----snip----
> > > Could you identify what you consider to be defective about C++'s
> > > post-increment semantic?
> >
> > It doesn't work with non-native types.
> > Post-decrement too, of course.
>
> You just have to defined custom operators where you want custom
> operators and then, if properly defined, they work fine.
Nope. With non-native types passed to functions they pass the
incremented value to the function.
> The post- operators take a dummy `int` argument, just to distinguish them.
I know. I spent weeks hacking the post- operators in an index class
designed to provide random access to a list class. Trying to hack
correct working into them. Managed it, but the hacks were ugly and
inefficient and prevented the compiler from picking up errors.
So LixtC, the indexor to ListC, has preincrements, but not post.
> Here's an example:
>
>
> #include <iostream>
> using namespace std; // Do this to get roughly pre-standard behavior.
Not me. Namespace is beyond the pale.
> struct Non_native
> {
> double amount;
>
> operator double() const { return amount; }
What's this for? It's not used, below.
>
> void advance()
> {
> amount += 0.01;
> }
>
> Non_native operator++( int )
double is non-native?
> {
> Non_native result = *this;
> advance();
> return result;
> }
> };
>
> int main()
> {
> Non_native o = {3.14};
>
> cout << "Originally " << o++ << "." << endl;
> cout << "After: " << o << "." << endl;
> }
I'm not even going to try it, Alf, And I bet you haven't done so.
That code requires overload operators = and << for the struct.