Sunday, April 5, 2020

Digest for comp.lang.c++@googlegroups.com - 17 updates in 2 topics

James Kuyper <jameskuyper@alumni.caltech.edu>: Apr 04 10:27PM -0400

On 4/4/20 9:33 AM, Ned Latham wrote:
>>>> Ned Latham wrote:
>>>>> Jorgen Grahn wrote:
>>>>>> Ned Latham wrote:
...
>> e.g. about lifetime of temporaries.
 
> I always regard those as lasting until their return.
 
I have no idea what "their return" is supposed to mean. The general rule
is that temporaries last until the end of the full-expression that
contains them. There's three main exceptions, the most important of
which occurs when a temporary is bound to a reference.
 
>> 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.
 
Well, he did say "if properly defined". To reproduce behavior comparable
to that for the built-in types, you need merely declare the operator
overload as returning a value of the same type, and define the operator
overload to create a copy of the current object before incrementing it,
and to return that copy. You won't get the behavior you've described
above if you follow those rules.
 
>> double amount;
 
>> operator double() const { return amount; }
 
> What's this for? It's not used, below.
 
That implements a conversion from Non-native to double, and it is used
below.
 
>> }
 
>> Non_native operator++( int )
 
> double is non-native?
 
No, but Non_native contains a double, and is implicitly convertible to a
double. I'm curious - how did you misinterpret the above code so as to
lead to that question?
 
>> {
>> Non_native o = {3.14};
 
>> cout << "Originally " << o++ << "." << endl;
 
You said that operator double() was not used. It might help you
understand this code to realize that it's equivalent to the following:
 
cout << "Originally " << o.operator++(1).operator double()
<< "." << endl;
 
If you don't understand why those two statements are equivalent, please
explain what part you do understand, and we can fill in the rest.
 
>> cout << "After: " << o << "." << endl;
 
Similarly, that line is equivalent to:
 
cout << "After: " << o.operator double() << "." << 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.
 
No, the rules of C++ cause operator double() to be called in each of the
relevant cases, and there are operators already defined for << working
on doubles. There's no need to declare or define operator=(); C++ rules
cause it to be implicitly declared and implicitly defined, and the
implicitly defined operator=() does precise what is needed. That's not
a coincidence - those rule were created specifically to save developers
the trouble of defining operator=() explicitly. You only need to
explicitly declare or define it in circumstance the implicit
declaration/definition doesn't do what you want it to do.
Mr Flibble <flibbleREMOVETHISBIT@i42.co.uk>: Apr 05 05:58AM +0100

On 04/04/2020 21:30, Sam wrote:
 
>> * If you would be willing to help, please get in touch via jgw@cognitionresearch.org. Please say something briefly about your experience with Visual C++, and the time you would have available to work on what I've described.
 
> It seems like you have very high standards, for accepting free help. I'm sure it would be an honor of a lifetime for someone to, most likely, sink massive amounts of time in cleaning up old code base that, most likely, was written by someone without much formal C++ training, knowledge, and experience; in exchange for recognition in some research paper that few people will ever read.
 
> This is obviously a drive-by posting, and this is likely just pissing into the wind: but you'll have far more success circulating your request amognst graduate students in Comp Sci in your institution of higher learning. I can't fathom anyone else caring to give a whit.
 
Give a whit? Typo there I think: give a shit is far more appropriate.
 
/Flibble
 
--
"Snakes didn't evolve, instead talking snakes with legs changed into snakes." - Rick C. Hodgin
 
"You won't burn in hell. But be nice anyway." – Ricky Gervais
 
"I see Atheists are fighting and killing each other again, over who doesn't believe in any God the most. Oh, no..wait.. that never happens." – Ricky Gervais
 
"Suppose it's all true, and you walk up to the pearly gates, and are confronted by God," Byrne asked on his show The Meaning of Life. "What will Stephen Fry say to him, her, or it?"
"I'd say, bone cancer in children? What's that about?" Fry replied.
"How dare you? How dare you create a world to which there is such misery that is not our fault. It's not right, it's utterly, utterly evil."
"Why should I respect a capricious, mean-minded, stupid God who creates a world that is so full of injustice and pain. That's what I would say."
Ned Latham <nedlatham@woden.valhalla.oz>: Apr 05 03:45AM -0500

James Kuyper wrote:
>>> 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.
 
----snip----
 
> What's with you? I only asked for a simple explanation for an obscure
> comment.
 
You got it.
 
----snip----
 
> OK, so you've made it clear that you're complaining about something you
> know little about.
 
Wrong. You've made clear that your reading and comprehension are
defective.
 
----snip----
Ned Latham <nedlatham@woden.valhalla.oz>: Apr 05 04:02AM -0500

Paavo Helde wrote:
> > > anywhere, are very useful, and I use them every day.
 
> > We're polar opposites then. I avoid them every day (including std::).
 
> Ignorance is bliss, they say.
 
Avoidance and ignorance aren't the same thing.
 
> > *sigh* I dunno. It looked like a good language thirty years ago. Some
> > hangover shit from C, but overall one of the best.
 
> C++ has many problems, but for me it's still the best language around.
 
I use it (for now) because I like the power and the conciseness and the
OO paradigm. But if I could find a language with those qualities, plus
some other quaqlities I deem important, I'd switch in a heartbeat; fact
is, its syntax and readability are woeful and its dependence on
parentheses is a PITA.
 
Not to mention the afore-mentioned versionitis.
 
> It has never let me down, regardless of how low-level I need to go in
> the implementation or how high level I want to go in the interfaces and
> design.
 
What programming language ever has?
 
> Most languages have built up high walls there, either in one (C)
 
You can go very high level in C with ADT's.
 
> or both directions (Java, C#, etc).
 
Never used either.
 
> You are right in that the current C++ (and especially its idiomatic use)
> is quite different from the pre-standard C++ dialects used in the last
> century.
 
In fact, they've made it *so* different that a new name would be
appropriate.
 
> If all your C++ knowlegde and experience becomes from year
> 1997,
 
That's a pretty stupid premise.
 
> this just means that every opinion you express about current C++
> is mostly just babbling.
 
And the conclusion's in that category too.
Ned Latham <nedlatham@woden.valhalla.oz>: Apr 05 04:06AM -0500

James Kuyper wrote:
> On 4/4/20 1:35 AM, Ned Latham wrote:
> > Ian Collins wrote:
> > > Ned Latham wrote:
 
----snip----
 
 
> > > Says who?
 
> > I do.
 
> If the only reason it's compulsory is because you said it,
 
I didn't. Try paying attention to what you read.
 
----snip----
Ned Latham <nedlatham@woden.valhalla.oz>: Apr 05 04:10AM -0500

David Brown wrote:
> Ned Latham wrote:
> > David Brown wrote:
 
----snip----
 
> > sensitive as making the object report the error to the caller.
 
> Do you assume that you know all the uses other people might have for
> features in a language?
 
Straw man. I know what exceptions are. And I repeat: it's nowhere near
as context-sensitive as making the object report the error to the caller.
 
----snip----
Ned Latham <nedlatham@woden.valhalla.oz>: Apr 05 04:19AM -0500

Ian Collins wrote:
 
> > > operator double() const { return amount; }
 
> > What's this for? It's not used, below.
 
> It is.
 
Liar.
 
 
> > 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.
 
> No, it doesn't.
 
Wrong.
 
> The code compiles and behaves exactly as intended
 
Your intention to produce defective code is noted.
 
> and
> your inability to comprehend it clearly demonstrates what I thought all
> along, you are clueless.
 
Wrong pronoun, dimwit.
Gerry Wolff <gerrywolff65@gmail.com>: Apr 05 02:49AM -0700

On Friday, 3 April 2020 18:35:45 UTC+1, Bonita Montero wrote:
> are not prone to buffer-overflows. You can disable this errors by
> defining _CRT_SECURE_NO_WARNINGS or you could use the safer versions
> the error-message shows you.
 
Many thanks for these and your other comments and suggestions that you made later.
 
With best wishes,
 
Gerry
Gerry Wolff <gerrywolff65@gmail.com>: Apr 05 02:56AM -0700

On Friday, 3 April 2020 21:01:37 UTC+1, Christian Gollwitzer wrote:
> Only in SP_new/: a.out
> Apfelkiste:Tests chris$
 
> Christian
 
Many thanks for these comments and suggestions.
 
With best wishes,
 
Gerry
Gerry Wolff <gerrywolff65@gmail.com>: Apr 05 03:21AM -0700

On Saturday, 4 April 2020 21:30:58 UTC+1, Sam wrote:
> the wind: but you'll have far more success circulating your request amognst
> graduate students in Comp Sci in your institution of higher learning. I
> can't fathom anyone else caring to give a whit.
 
Contrary to what you suggest, I've had a brilliant response from someone who has done a very thorough review and updating of my SP71 C++ program. I could not have asked for more.
 
Gerry
James Kuyper <jameskuyper@alumni.caltech.edu>: Apr 05 11:04AM -0400

On 4/5/20 5:06 AM, Ned Latham wrote:
>> On 4/4/20 1:35 AM, Ned Latham wrote:
>>> Ian Collins wrote:
>>>> Ned Latham wrote:
...
>>>>> Now, it seems, its use is compulsory.
 
>>>> Says who?
 
As a response to that comment, "Says who" should be interpreted as a
short form for the question "Who says that it's use is compulsory?".
 
>>> I do.
 
Which, in context, should mean "I say that it's use is compulsory.",
which is technically correct, since you did in fact say that in the your
immediately previous question - the line where you say precisely that is
still quoted at the top of this message. It seems, however, from your
response below, that this is not what you actually meant to say.
 
That's fine, because that's not actually the kind of answer he was
looking for. You were clearly merely describing something that you
didn't approve of. What he should have asked is "Who's making it
compulsory?". He's asking that for a very simple reason - he's not aware
of anyone having done so. Neither am I. If someone who has the authority
to do so is going to make it compulsory for me to use namespaces, then I
want to know who it is, so I can start the process of removing them from
authority. So could you please identify who that is?
 
>> If the only reason it's compulsory is because you said it,
 
> I didn't. ...
 
First you say "I do.", and now you're denying it?
 
On 4/4/20 12:58 AM, Ned Latham wrote:
> I don't know when it was introduced, but in his book (vol 3) Stroustrup
> seems to imply that it's a new thing. He discusses, for example,
> "transitioning" to it. Now, it seems, its use is compulsory.
 
And, as far as I know, that text, written by you, is the only text
anywhere that says that use of namespaces is compulsory. If I'm wrong
about that, please identify another piece of text that says so.
James Kuyper <jameskuyper@alumni.caltech.edu>: Apr 05 11:27AM -0400

On 4/5/20 5:19 AM, Ned Latham wrote:
> Ian Collins wrote:
>> On 05/04/2020 02:33, Ned Latham wrote:
>>> Alf P. Steinbach wrote:
...
 
>>> What's this for? It's not used, below.
 
>> It is.
 
> Liar.
 
Give it a try. Modify that definition to monitor calls to that function:
 
operator double() const {
cout << endl << "Conversion from Non_native to double performed:"
<< amount << endl;
return amount.
}
 
 
>> No, it doesn't.
 
> Wrong.
 
>> The code compiles and behaves exactly as intended
 
Give it a try. Try to compile it, and you'll find it will compile
without error messages, and it shouldn't trigger any warnings, either.
Try to link it, and you'll find that it will link. Try to execute it,
and it will execute and produce output showing that the return value of
operator++ is the value before the increment, while the value stored in
o is the value after the increment. And if you add the monitoring that I
recommended, you'll find that operator double() is called twice. Here's
the results when I do it:
 
~/Programming/C++/testprog(57) g++ -std=c++98 -pedantic -Wall
-Wpointer-arith -Wcast-align -fno-enforce-eh-specs -ffor-scope
-fno-gnu-keywords -fno-nonansi-builtins -Wctor-dtor-privacy
-Wnon-virtual-dtor -Wold-style-cast -Woverloaded-virtual -Wsign-promo
post-increment.cpp -o post-increment
~/Programming/C++/testprog(58) post-increment
Originally
Conversion from Non_native to double performed:3.14
3.14.
After:
Conversion from Non_native to double performed:3.15
3.15.
 
I used C++98, since you prefer old versions of C++, and that's the
oldest version gcc supports. It also produces the same results when
compiled using the latest version of C++ it supports.
Note that the other options I used are mainly to ensure that it produces
all of the warnings I consider reasonable - feel free to modify that
list. Let me know if you find an option whose addition or removal gives
you different results from mine.
 
> Your intention to produce defective code is noted.
 
That the above code has the behavior shown is guaranteed by the C++
standard (all versions).
Mr Flibble <flibbleREMOVETHISBIT@i42.co.uk>: Apr 05 04:31PM +0100

On 05/04/2020 10:10, Ned Latham wrote:
>> features in a language?
 
> Straw man. I know what exceptions are. And I repeat: it's nowhere near
> as context-sensitive as making the object report the error to the caller.
 
I nearly always check error and convert it into an exception: this is the correct thing to do as attempting to manually propagate errors up the call stack is tedious, antiquated and fucktarded.
 
/Flibble
 
--
"Snakes didn't evolve, instead talking snakes with legs changed into snakes." - Rick C. Hodgin
 
"You won't burn in hell. But be nice anyway." – Ricky Gervais
 
"I see Atheists are fighting and killing each other again, over who doesn't believe in any God the most. Oh, no..wait.. that never happens." – Ricky Gervais
 
"Suppose it's all true, and you walk up to the pearly gates, and are confronted by God," Byrne asked on his show The Meaning of Life. "What will Stephen Fry say to him, her, or it?"
"I'd say, bone cancer in children? What's that about?" Fry replied.
"How dare you? How dare you create a world to which there is such misery that is not our fault. It's not right, it's utterly, utterly evil."
"Why should I respect a capricious, mean-minded, stupid God who creates a world that is so full of injustice and pain. That's what I would say."
Ned Latham <nedlatham@woden.valhalla.oz>: Apr 05 11:31AM -0500

James Kuyper wrote:
 
> > > > > Says who?
 
> As a response to that comment, "Says who" should be interpreted as a
> short form for the question "Who says that it's use is compulsory?".
 
Wrong.
 
> > > > I do.
 
> Which, in context, should mean "I say that it's use is compulsory.",
 
Wrong.
 
----snip----
 
> > > If the only reason it's compulsory is because you said it,
 
> > I didn't. ...
 
> First you say "I do.", and now you're denying it?
 
Wrong.
 
> > "transitioning" to it. Now, it seems, its use is compulsory.
 
> And, as far as I know, that text, written by you, is the only text
> anywhere that says that use of namespaces is compulsory.
 
And you're wrong again.
 
> If I'm wrong
> about that, please identify another piece of text that says so.
 
That's not the only alternative to your idiot misinterpretation.
 
Learn to read.
Ned Latham <nedlatham@woden.valhalla.oz>: Apr 05 11:37AM -0500

Mr Flibble wrote:
 
> I nearly always check error and convert it into an exception: this is the
> correct thing to do as attempting to manually propagate errors up the call
> stack is tedious,
 
One level is all it takes.
 
> antiquated
 
So's breathing. So what?
 
> and fucktarded.
 
You can always try Flubbing it.
James Kuyper <jameskuyper@alumni.caltech.edu>: Apr 05 04:59PM -0400

On 4/5/20 12:31 PM, Ned Latham wrote:
 
>> As a response to that comment, "Says who" should be interpreted as a
>> short form for the question "Who says that it's use is compulsory?".
 
> Wrong.
 
OK - so you've made it clear that you're misunderstanding ordinary
English sentences. However, that's not a particular useful response,
because it lacks an explanation. As a result, I have no idea which
misunderstanding of that sentence is the one you believe to be correct.
 
This is long overdue - Plonk.
David Brown <david.brown@hesbynett.no>: Apr 05 02:15PM +0200

On 04/04/2020 21:49, Tim Rentsch wrote:
>> couldn't think of.
 
> Not correct. It implicitly allows for such a possibility, but not
> explicitly.
 
He wrote "I can't think of any" - that is explicit in stating the
limitations of his first sentence. Implicit/explicit is not a binary
choice, but a sliding scale, and I personally would judge Keith's
wording to be towards the explicit end here.
 
>> enlighten him about what such reasons might be.
 
> Yes it could. His comment also could be interpreted as hinting that
> he thinks there are no good reasons.
 
I think it was obvious to most people from Keith's wording that he
thought there could at least be reasons (for having different parameter
names) that other people consider "good", even though he may be
sceptical as to whether /he/ would consider them "good".
 
 
>> Can you so enlighten him?
 
> AFAIK he isn't seeking enlightenment, and I wouldn't presume to
> suppose otherwise.
 
I am not sure I believe you have this interpretation of what he wrote.
I am wary of accusing you of lying here - that would be a step too far.
But I think you are being deliberately misrepresentative. If you tell
me I am incorrect here, I will accept that.
 
I think it is obvious to most people that he /was/ looking for
enlightenment - he was inviting anyone with knowledge or examples
contrary to his experience, to share them.
 
From past experience of your posts, it is likely that you will have
knowledge of situations where people use different parameter names for
reasons that they think are good. And it will many posts, dragged out
over months, before you are persuaded to reveal any.
 
 
>> If not, there was really no point in responding.
 
> Your purposes are not my purposes.
 
James' purposes appear to me to be mainly about learning and spreading
knowledge, discussing topics he finds interesting and enlightening,
trying to improve the knowledge and understanding of C++ and programming
amongst the followers of this group, and perhaps providing interest and
entertainment for himself and others.
 
What are your purposes here?
You received this digest because you're subscribed to updates for this group. You can change your settings on the group membership page.
To unsubscribe from this group and stop receiving emails from it send an email to comp.lang.c+++unsubscribe@googlegroups.com.

No comments: