Wednesday, February 5, 2020

Digest for comp.lang.c++@googlegroups.com - 24 updates in 4 topics

queequeg@trust.no1 (Queequeg): Feb 05 03:47PM

> and race are somehow linked to intelligence? Only racists look at
> races and then make generalizations about them relating to things
> like intelligence, abilities, competence and the like.
 
So this is a coincidence then.
 
http://worldpopulationreview.com/countries/average-iq-by-country/
 
;)
 
--
https://www.youtube.com/watch?v=9lSzL1DqQn0
Bo Persson <bo@bo-persson.se>: Feb 05 05:05PM +0100

On 2020-02-05 at 16:47, Queequeg wrote:
 
> So this is a coincidence then.
 
> http://worldpopulationreview.com/countries/average-iq-by-country/
 
> ;)
 
You did notice this part, right?
 
" IQ scores typically reflect the quality of education "
 
 
For example, if you were never taught how to read, you will score
extremely badly on a standardized test.
Siri Cruise <chine.bleu@yahoo.com>: Feb 05 02:12PM -0800

In article <r0m5jr$2tdm$1@adenine.netfront.net>,
> > Babylonians of Irak were racially arabs, read about them here:
 
> Why are you applying categorizations of intelligence to a particular
> ethnic group? Are you a racist? You honestly think that ethnicity
 
The US as a whole is racist against arabs. Not as badly treated
as blacks, but like 'black is beautiful' to retain sanity, I can
see an 'arab is beautiful'. Be honest: when you here 'arab woman'
are you thinking Salma Hayek or Olga the Soviet tractor factory
worker?
 
It can be taken too far, but wait for evidence of that. By the
way, Green is Beautiful:
https://www.youtube.com/watch?v=fYvU7oBBgKA
 
--
:-<> Siri Seal of Disavowal #000-001. Disavowed. Denied. Deleted. @
'I desire mercy, not sacrifice.' /|\
The first law of discordiamism: The more energy This post / \
to make order is nore energy made into entropy. insults Islam. Mohammed
"Alf P. Steinbach" <alf.p.steinbach+usenet@gmail.com>: Feb 06 12:00AM +0100

On 05.02.2020 23:12, Siri Cruise wrote:
> Be honest: when you here 'arab woman'
> are you thinking Salma Hayek or Olga the Soviet tractor factory
> worker?
 
I googled Salma and she's a Mexican-American, not an Arab.
 
<url: https://en.wikipedia.org/wiki/Salma_Hayek>
 
• • •
 
Arabic women probably look like Effinna:
 
<url: https://www.instagram.com/effinna/>
 
• • •
 
Or maybe like one of these 11 more or less famous ones:
 
<url:
https://stepfeed.com/11-inspirational-arab-women-making-a-difference-in-the-world-1280>
 
- Alf
Juha Nieminen <nospam@thanks.invalid>: Feb 05 07:19AM


>> Unfortunately they forgot to make it safe to copy
 
> CopyConstructible, CopyAssignable, and "can be copied efficiently" would
> seem to cover all the bases. What did they leave out?
 
I think there's a difference between "can be copied" and "safe to copy".
In this case it might not be considered "safe to copy" if copying may
throw an exception.
Keith Thompson <Keith.S.Thompson+u@gmail.com>: Feb 05 12:20AM -0800

> On 5.02.2020 0:39, Keith Thompson wrote:
>> Paavo Helde <myfirstname@osa.pri.ee> writes:
[...]
 
> Not much, typically. However, most C++ code resides in various
> libraries, and a library should not decide on terminating the program
> on its own, this should be the privilege of the main program.
 
And returning "memory exhausted" doesn't give the main program enough
information to decide that it should terminate.
 
[...]
 
> treat an error message as data. It might change whenever someone feels
> he can word the message better, and will certainly change when the
> program is translated to French.
 
And how is the caller of a string copying function to know that the
"memory exhausted" string it returns is an error message rather than
data?
 
> which is meant for programmatic consumption. Copying this integer does
> not involve dynamic memory allocation, so there would be no danger of
> exceptions when copying that.
 
Sure, if you have *some* out-of-band way to signal errors (not
necessarily exceptions), you'll use that rather than returning
"memory exhausted" as data. Depending on how you represent strings, a
null pointer might make sense.
 
--
Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com
Working, but not speaking, for Philips Healthcare
void Void(void) { Void(); } /* The recursive call of the void */
Robert Wessel <robertwessel2@yahoo.com>: Feb 05 04:19AM -0600

On Wed, 5 Feb 2020 07:19:07 -0000 (UTC), Juha Nieminen
 
>I think there's a difference between "can be copied" and "safe to copy".
>In this case it might not be considered "safe to copy" if copying may
>throw an exception.
 
 
I'm a little puzzled why this might throw an exception during a copy,
or what case the standard appears to be catering to by allowing one.
The obvious implementation of the structure would be two integers and
two pointers to constant strings, or a single pointer to a constant
structure containing those four items in some fashion.
 
Sure, I can imaging storing one or both two strings as part of the
structure, but why on earth would anyone do that?
Paavo Helde <myfirstname@osa.pri.ee>: Feb 05 12:56PM +0200

On 5.02.2020 10:20, Keith Thompson wrote:
>> on its own, this should be the privilege of the main program.
 
> And returning "memory exhausted" doesn't give the main program enough
> information to decide that it should terminate.
 
That's right, and it is not clear at all the main program should
terminate. The original exception was raised not because of memory
exhaustion (otherwise it would be a std::bad_alloc), but because of
something else. The reaction should depend on the exception dynamic type
and potentially on any extra info it carries, instead of the (inherently
fragile) error message.
 
Even if there is a std::bad_alloc exception, it does not mean that
something is so bad the program should terminate. Maybe the user just
wanted to read in a really huge image and a 10 GB memory allocation
failed. A failure of such memory allocation request has no ill effect on
the OS or program state, the program can just inform user this image
cannot be loaded at the moment.
 
 
 
> And how is the caller of a string copying function to know that the
> "memory exhausted" string it returns is an error message rather than
> data?
 
Such static string would not be returned from a string copying function,
but from the exception class what(). This would probably mean some
nullptr stored in the exception object, or something.
 
The point I wanted to make is really simple: if the system has run out
of memory so seriously that an error message cannot be copied, then it
most probably does not matter any more which error message it was, and
thus there is no need to invent extra clever schemes for trying to
preserve it.
 
> necessarily exceptions), you'll use that rather than returning
> "memory exhausted" as data. Depending on how you represent strings, a
> null pointer might make sense.
 
An exception object can store more data than just a string or a string
pointer. I would not call this extra data out-of-band.
Ned Latham <nedlatham@woden.valhalla.oz>: Feb 05 05:22AM -0600

Keith Thompson wrote:
> > on its own, this should be the privilege of the main program.
 
> And returning "memory exhausted" doesn't give the main program enough
> information to decide that it should terminate.
 
It should do. The caller knows where it issued the call and with what
parameters. Good way to keep bugs out of code.
 
 
> And how is the caller of a string copying function to know that the
> "memory exhausted" string it returns is an error message rather than
> data?
 
That depends on your string library. Mine always returns either a string
class object or an unsinged int. In both cases a zero return indicates
an error, and the caller can inspect the string for more detail on the
error. The language of that depends on the library, not the data.
 
----snip----
Keith Thompson <Keith.S.Thompson+u@gmail.com>: Feb 05 12:15PM -0800


> The only exception scenario in string copying is memory
> exhaustion. Nowadays I would just silence this and return a static
> string like "memory exhausted" from what() if copying failed.
[...]
 
Please disregard most of what I've written in this thread.
I misunderstood what Paavo was saying. I forgot that "what()" is
the name of a function that returns information about an exception,
and thought that he was talking about having the string copying
function itself return the string "memory exhausted". I should
have read more carefully. (The term "noexcept" also threw me off
from considering exception semantics.)
 
Sorry about the noise.
 
--
Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com
Working, but not speaking, for Philips Healthcare
void Void(void) { Void(); } /* The recursive call of the void */
Keith Thompson <Keith.S.Thompson+u@gmail.com>: Feb 05 12:16PM -0800

Paavo Helde <myfirstname@osa.pri.ee> writes:
[...]
> Such static string would not be returned from a string copying
> function, but from the exception class what(). This would probably
> mean some nullptr stored in the exception object, or something.
[...]
 
And that's the part that I misunderstood. See my reply upthread.
 
--
Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com
Working, but not speaking, for Philips Healthcare
void Void(void) { Void(); } /* The recursive call of the void */
fir <profesor.fir@gmail.com>: Feb 04 03:54PM -0800

W dniu środa, 5 lutego 2020 00:22:31 UTC+1 użytkownik fir napisał:
> > of code to give you a start.
 
> snake is nota porblem, problem is this insanelly vrappy language which disallows
> even poting this 3 things (window, food, snake) niecly put together
 
when i get back to it once a 10 years it is again only like "only for idiots"
fir <profesor.fir@gmail.com>: Feb 05 07:15AM -0800

W dniu środa, 5 lutego 2020 00:55:09 UTC+1 użytkownik fir napisał:
 
> > snake is nota porblem, problem is this insanelly vrappy language which disallows
> > even poting this 3 things (window, food, snake) niecly put together
 
> when i get back to it once a 10 years it is again only like "only for idiots"
 
 
extremally frustrating youre just like cant do it well (by "it" i mean the think i wrote initially, or at least something close
 
what goals are
 
1) i want to have objects connected by reference (thise references are obiect fields
like
a) Snake has a field Window& window
Snake has a field Food& food
b) Food has a field Window& window
c) Window has a field Snake& snake
Window has a field Food& food
 
i also want this references to be initialised in a poblem-lacking way,
this thing is problem lackng when
those objects take those refrences in a momnet fo creation, as this guarantees
evereything must be ok
 
2) this seems that this crappy language doeas not allow that
3) and a tries used to find something close arso failed (though something more or less crappy probably cant be found
4) more to say my all tries needed a
numerious tries when i changed the presence of those object from one place to another changed also places where those references were passed 9from constructors to functions), also changed it from references to pointers and vice versa, which involved idiotc changes in
biodies of those object codes..those changes was so utelly crapopy activiry normal language like c dont even know,
thios is simply 'sceptic tank' (pool/pond od shit) for years of c i managed to forget how this shit stinks
Bo Persson <bo@bo-persson.se>: Feb 05 04:58PM +0100

On 2020-02-05 at 16:15, fir wrote:
> those objects take those refrences in a momnet fo creation, as this guarantees
> evereything must be ok
 
> 2) this seems that this crappy language doeas not allow that
 
Ok...
 
So to be able to create a Food object, you first need to create a
Window. But before you can create the Window, you first have to create
the Food. Oh, and the Snake. But before you create the Snake...
 
 
Perhaps it is time to consider that some statements cannot be
formulated, however powerful a logic system you have. Not limited to
programming languages.
 
For example, the liar paradox https://en.wikipedia.org/wiki/Liar_paradox
 
A: This statement (A) is false.
 
If (A) is true, then "This statement is false" is true. Therefore, (A)
must be false. The hypothesis that (A) is true leads to the conclusion
that (A) is false, a contradiction.
 
If (A) is false, then "This statement is false" is false. Therefore, (A)
must be true. The hypothesis that (A) is false leads to the conclusion
that (A) is true, another contradiction. Either way, (A) is both true
and false, which is a paradox.
 
 
Not even C++ can solve this. :-)
fir <profesor.fir@gmail.com>: Feb 05 08:17AM -0800

W dniu środa, 5 lutego 2020 16:58:27 UTC+1 użytkownik Bo Persson napisał:
> that (A) is true, another contradiction. Either way, (A) is both true
> and false, which is a paradox.
 
> Not even C++ can solve this. :-)
 
 
atatemant A has not much to it
 
as to those references its physically totally able to get, you simpl may think you create a thing in one step or simply
cretere part of each (lke place them in ram so they got adresses) then you set the references
 
so its doable (this reference is mere a pointer anywey) but my question is fdifferent; if this crappy language dont allows me to do it (or maybe it does? by some trick or what) how the most close thing i can obtain?
 
(and note i get extrelmly frustrated yesterday by drowning in a swamp of deep shit trials of it,, as it was real swampshit..i got no strength to try)
 
so? maybe somebody is able to answer?
 
fibble said something but i dont see it cleraly so maybe some eleboration?
Jorgen Grahn <grahn+nntp@snipabacken.se>: Feb 05 07:17PM

On Wed, 2020-02-05, fir wrote:
>> > > > im eben somewhat experienced c coder
>> > > > but got no experience in writing c++ or any OOP
 
>> > > > the question is say i gare smal snake game made in sfml, i want to have 3 objects
...
 
> activiry normal language like c dont even know, thios is simply
> 'sceptic tank' (pool/pond od shit) for years of c i managed to
> forget how this shit stinks
 
I see deciding not to try to help you was a wise decision.
 
/Jorgen
 
--
// Jorgen Grahn <grahn@ Oo o. . .
\X/ snipabacken.se> O o .
Juha Nieminen <nospam@thanks.invalid>: Feb 05 07:23PM

> 2) this seems that this crappy language doeas not allow that
 
If you really want help to whatever problem you are having,
then perhaps it would be a better idea to be a bit more polite.
 
Of course putting some effort into writing something that's easier
to understand also helps.
fir <profesor.fir@gmail.com>: Feb 05 11:36AM -0800

W dniu środa, 5 lutego 2020 20:18:04 UTC+1 użytkownik Jorgen Grahn napisał:
> > 'sceptic tank' (pool/pond od shit) for years of c i managed to
> > forget how this shit stinks
 
> I see deciding not to try to help you was a wise decision.
 
but do informing me on that was?
if you se word help better stay away..
im pryty sure anybody on usenet who names an answer as an "help" is realy heavy idiot, much below the IQ level i could tolerate
 
same kind of idiot who could name a help really anything - were in fact exchanging messages with idiots is rather annoying ;c
 
so tnx much and keep away
"Alf P. Steinbach" <alf.p.steinbach+usenet@gmail.com>: Feb 05 09:08PM +0100

On 05.02.2020 16:58, Bo Persson wrote:
> Either way, (A) is both true and false
 
No, A is neither true nor false.
 
You have just proved it can't be either. So it's neither.
 
:-)
 
- Alf
Bonita Montero <Bonita.Montero@gmail.com>: Feb 05 04:35PM +0100

If I create a wofsteam with MSVC, I get a simple ASCII-output, i.e. the
Unicode-codepoints aren't translated to UTF-8. I can't even output a
Unicode-character >= '\u0100', i.e. the failbit will be set then. Can
anyone here tell me how to create a output stream with UTF-8-encoding ?
Bo Persson <bo@bo-persson.se>: Feb 05 05:01PM +0100

On 2020-02-05 at 16:35, Bonita Montero wrote:
> Unicode-codepoints aren't translated to UTF-8. I can't even output a
> Unicode-character >= '\u0100', i.e. the failbit will be set then. Can
> anyone here tell me how to create a output stream with UTF-8-encoding ?
 
This has not so much to do with the stream as with the locale.
 
 
Bo Persson
Ben Bacarisse <ben.usenet@bsb.me.uk>: Feb 05 04:05PM


> If I create a wofsteam with MSVC, I get a simple ASCII-output, i.e. the
> Unicode-codepoints aren't translated to UTF-8. I can't even output a
> Unicode-character >= '\u0100',
 
That's not a wide character but a multi-character constant. You want
 
L'\x0100'
 
instead. That's a value of type wchar_t.
 
> i.e. the failbit will be set then. Can
> anyone here tell me how to create a output stream with UTF-8-encoding ?
 
On my system, this works as expected:
 
#include <fstream>
#include <locale>
 
int main()
{
std::wofstream wos("out");
wos.imbue(std::locale("en_GB.UTF8"));
wos << L'\x0100';
}
 
but that's with g++ on Linux not MSVC.
 
--
Ben.
"Alf P. Steinbach" <alf.p.steinbach+usenet@gmail.com>: Feb 05 09:05PM +0100

On 05.02.2020 16:35, Bonita Montero wrote:
> Unicode-codepoints aren't translated to UTF-8. I can't even output a
> Unicode-character >= '\u0100', i.e. the failbit will be set then. Can
> anyone here tell me how to create a output stream with UTF-8-encoding ?
 
Well, a wide output stream translates from the wide encoding (UTF-16 in
Windows) to the external byte encoding (the ANSI codepage in Windows).
 
Windows only recently, in the May 2019 update of Windows 10, got support
for UTF-8 as ANSI encoding. To enable that for your application you can
add a special manifest setting with a brittle spaces-are-significant
syntax. See <url:
https://alfps.wordpress.com/2020/01/03/a-windows-h-wrapper-for-utf-8-windows-apps/>
for details.
 
Alternatively, if you're only using Visual C++ and don't plan on
supporting other compilers, then you can use `_setmode`. See (currently)
<url:
https://docs.microsoft.com/en-us/cpp/c-runtime-library/reference/setmode?view=vs-2019>.
 
Third alternative, there is a Boost sublibrary for UTF-8 i/o. When I
checked it out, right around its Boost adoption, because its author
referred to a blog article of mine, it was brittle and with some trivial
nasty bugs (like forgetting to remove carriage return in input). But
maybe it has benefited from Boost-ing, and it may do the job for you.
 
<rant>
This is IMO all very Windows-specific, not C++, i.e. off-topic here,
except for iostreams' curious lack of support for encodings, which is
needed critical functionality, and the ditto curious forced use of
[beep] archaic & over-engineered complex limited locale functionality,
which is not needed and cause a very undesired inefficiency.
</rant>
 
- Alf
"Alf P. Steinbach" <alf.p.steinbach+usenet@gmail.com>: Feb 05 09:07PM +0100

On 05.02.2020 17:01, Bo Persson wrote:
>> Unicode-character >= '\u0100', i.e. the failbit will be set then. Can
>> anyone here tell me how to create a output stream with UTF-8-encoding ?
 
> This has not so much to do with the stream as with the locale.
 
Windows still does not have an UTF-8 locale for ordinary applications.
 
Since May 2019 one may however outfit an application with a manifest
that causes it to have UTF-8 as the process ANSI codepage.
 
 
- Alf
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: