Tuesday, October 2, 2018

Digest for comp.lang.c++@googlegroups.com - 25 updates in 6 topics

Ralf Goertz <me@myprovider.invalid>: Oct 02 11:45AM +0200

Am Sun, 30 Sep 2018 10:58:08 -0700
> > [un]signed char [...]?
 
> They can be. They don't have to be, but they can be. (I should
> add, certainly in C, and I am pretty sure for C++.)
 
But if they are separate types they need to overload the stream
operators "<<" and ">>" in the same way the char types do, right?
Otherwise a respective program would behave differently, depending on
these types being separate or typedefs. Which would make the advantage
of them being separate types moot.
Paul <pepstein5@gmail.com>: Oct 02 12:58AM -0700

Suppose I code a function to perform f() a user_specified number of times.
A natural first attempt would be
 
void perform_f(int numTrials)
{
 
for(int i = 0; i < numTrials; ++i)
f();
}
 
In an improvement, I decide that I don't want negative input to be
acceptable because a negative number of trials doesn't make sense.
I'm more ambitious than just writing a message about it.
I simply don't want a negative numTrials to be a possibility in the first place.
 
So a second attempt could simply change the signature
to void perform_f(unsigned numTrials)
If I don't want the compiler to give any warnings,
I should use unsigned in the for loop too.
 
But this is even worse.
If a caller of perform_f erroneously sets numTrials to -1
the number of trials performed is UINT_MAX which is unlikely to
be what the caller wants.
 
My solution?
Create a new integerType class
IntegerType(int underlying)
which throws an exception in the constructor when a user tries to make the instantiation of the underlying integer positive.
 
Is this what's done in practice?
If not, what is the standard solution?
 
Many thanks for your advice.
 
Paul
Paul <pepstein5@gmail.com>: Oct 02 01:01AM -0700

On Tuesday, October 2, 2018 at 8:58:35 AM UTC+1, Paul wrote:
> If not, what is the standard solution?
 
> Many thanks for your advice.
 
> Paul
 
I meant
"exception in the constructor when a user tries to make the underlying
integer negative".
 
Apologies for the error.
 
Thanks,
 
Paul
Daniel <danielaparker@gmail.com>: Oct 02 02:22AM -0700

On Tuesday, October 2, 2018 at 3:58:35 AM UTC-4, Paul wrote:
 
> If a caller of perform_f erroneously sets numTrials to -1
> the number of trials performed is UINT_MAX which is unlikely to
> be what the caller wants.
 
I don't think that case is any different from the caller
setting numTrials to _any_ erroneous number, whether that be
2 or 2000000 or UINT_MAX or whatever. If you like, you
can validate that numTrials is within a permissible range.
 
Daniel
"Chris M. Thomasson" <invalid_chris_thomasson@invalid.invalid>: Oct 01 04:17PM -0700

On 10/1/2018 11:52 AM, Christian Gollwitzer wrote:
> does not need to be "engineered". Who put the beautiful patterns in the
> Mandelbrot fractal set? Nobody. They are not even there, your brain
> infers them from a mathematical structure and thinks "oh, great designer"
 
There are some interesting patterns in them there hills... ;^)
 
 
"Chris M. Thomasson" <invalid_chris_thomasson@invalid.invalid>: Oct 01 04:20PM -0700

On 10/1/2018 12:18 PM, Rick C. Hodgin wrote:
>> earth is, or how old fossils are?
 
> I can't make you believe, Juha. If you want to know the truth,
> the information is available to you. Seek it out.
 
Fwiw, I always thought the the book of Job mentioned the "Behemoths"...
Was it referencing dinosaurs? Iirc, some said they had a tail the size
of the trunk of the Cedars of Lebanon.
Reinhardt Behm <rbehm@hushmail.com>: Oct 02 09:57AM +0800

AT Tuesday 02 October 2018 03:39, Rick C. Hodgin wrote:
 
> The Bible refers to this as the golden age. Over time it's been
> winding down, and has seen the silver age, the bronze age, and
> now we're in a new age of iron and baked clay, which do not mix.
 
You tell us that your "great designer" was not able to see this and design
something sustainable. I would call this a bad hack, not the result of
"intelligent" design.
 
> thing, and use it too. In Heaven, we can use our possessions and
> they won't go away. Like Moses with the fire in the burning bush,
> but the wood was not consumed.
 
And now you tell us that we should trust this bad hacker to have created
something that will last.
No thanks I only buy from reliable suppliers.
 
--
Reinhardt
"Rick C. Hodgin" <rick.c.hodgin@gmail.com>: Oct 01 09:01PM -0700

On Monday, October 1, 2018 at 9:57:49 PM UTC-4, Reinhardt Behm wrote:
 
> You tell us that your "great designer" was not able to see this and design
> something sustainable. I would call this a bad hack, not the result of
> "intelligent" design.
 
There's a teaching here you miss. God created everything perfect.
It was man's sin that destroyed that perfection.
 
 
> And now you tell us that we should trust this bad hacker to have created
> something that will last.
> No thanks I only buy from reliable suppliers.
 
God's Kingdom is eternal. Sin is only here in this world. It is
His Kingdom He calls us to, not this world.
 
--
Rick C. Hodgin
Ian Collins <ian-news@hotmail.com>: Oct 02 05:18PM +1300

On 01/10/18 23:28, Rick C. Hodgin wrote:
 
> Dinosaurs (with man in history, hundreds of real-world
> documentation sources showing dinosaurs living with man):
 
https://letterstocreationists.wordpress.com/dinosaur-soft-tissue/
 
> Seek the truth honestly and truly. Accept nothing less. Ever.
 
Learn from your own songbook.
 
--
Ian.
Reinhardt Behm <rbehm@hushmail.com>: Oct 02 12:49PM +0800

AT Tuesday 02 October 2018 12:01, Rick C. Hodgin wrote:
 
>> result of "intelligent" design.
 
> There's a teaching here you miss. God created everything perfect.
> It was man's sin that destroyed that perfection.
 
He created everything. So he also created sin. Bad design, incompetent
designer. Broken by design.
 
 
--
Reinhardt
Juha Nieminen <nospam@thanks.invalid>: Oct 02 05:30AM

>> earth is, or how old fossils are?
 
> I can't make you believe, Juha. If you want to know the truth,
> the information is available to you. Seek it out.
 
I notice that you never answer any questions. I'll take that as a sign
that you don't have any answers.
 
You don't understand the theory of evolution, you don't understand
anything about science, and the only thing you are doing is parroting
other young earth creationists, and avoiding answering any questions.
You have no interest in actually having a conversation, you only spout
doctrine like a mindless robot.
Juha Nieminen <nospam@thanks.invalid>: Oct 02 05:31AM

> Fwiw, I always thought the the book of Job mentioned the "Behemoths"...
> Was it referencing dinosaurs? Iirc, some said they had a tail the size
> of the trunk of the Cedars of Lebanon.
 
No, it says that the tail moves like a cedar. Even creationists can't read
their own scripture.
Juha Nieminen <nospam@thanks.invalid>: Oct 02 05:32AM

> On Monday, October 1, 2018 at 6:28:44 AM UTC-4, Rick C. Hodgin wrote:
>> Seek the truth honestly and truly. Accept nothing less. Ever.
 
> I was an atheist.
 
What you are is a liar, plain and simple.
"Chris M. Thomasson" <invalid_chris_thomasson@invalid.invalid>: Oct 01 11:45PM -0700

On 10/1/2018 10:31 PM, Juha Nieminen wrote:
>> of the trunk of the Cedars of Lebanon.
 
> No, it says that the tail moves like a cedar. Even creationists can't read
> their own scripture.
 
I was just trying to remember if cedar was even in there.
David Brown <david.brown@hesbynett.no>: Oct 02 09:28AM +0200

On 02/10/18 03:57, Reinhardt Behm wrote:
 
> You tell us that your "great designer" was not able to see this and design
> something sustainable. I would call this a bad hack, not the result of
> "intelligent" design.
 
The "intelligent" design crowd are very fond of looking at things around
them, failing to understand them, and thinking that means there must
have been a designer. A classic case is the human eye - they can't see
the point of "half an eye", therefore they don't think it evolved. I'd
suggest they look closer at the human eye and see just how /badly/
designed it really is. As a divine biology project, it would get a D-
with a "see me afterwards about the blatant plagiarism of fish eyes
without understanding the principles involved".
 
If you want proof of the non-existence of a "great designer", look to
the mistakes, the hacks, the workarounds that surround us.
"Chris M. Thomasson" <invalid_chris_thomasson@invalid.invalid>: Oct 01 04:15PM -0700

On 10/1/2018 3:53 PM, Chris M. Thomasson wrote:
 
>> Good random number generators version 1.0, you can port them to C++
 
> Really random? Humm... How do they compare to a hardware TRNG?
 
> ;^)
 
Fwiw, here is a 100% purely experimental thing I created, that can
generate some "interesting" bits:
 
https://groups.google.com/d/topic/comp.lang.c++/7u_rLgQe86k/discussion
 
;^)
 
"Chris M. Thomasson" <invalid_chris_thomasson@invalid.invalid>: Oct 01 03:53PM -0700

On 10/1/2018 2:16 PM, Horizon68 wrote:
> Hello,
 
> Read this:
 
> Good random number generators version 1.0, you can port them to C++
 
Really random? Humm... How do they compare to a hardware TRNG?
 
;^)
 
[...]
"Öö Tiib" <ootiib@hot.ee>: Oct 01 10:07PM -0700

On Tuesday, 2 October 2018 02:15:56 UTC+3, Chris M. Thomasson wrote:
> generate some "interesting" bits:
 
> https://groups.google.com/d/topic/comp.lang.c++/7u_rLgQe86k/discussion
 
> ;^)
 
Undefined behavior (like your race condition) means that next version of
compiler can assume it can't happen and "optimize" it away.
"Chris M. Thomasson" <invalid_chris_thomasson@invalid.invalid>: Oct 01 10:12PM -0700

On 10/1/2018 10:07 PM, Öö Tiib wrote:
 
>> ;^)
 
> Undefined behavior (like your race condition) means that next version of
> compiler can assume it can't happen and "optimize" it away.
 
Just to clarify, my race condition thing is using standard atomic loads
and stores with relaxed memory ordering. There is no undefined behavior
wrt the logic that is generating the contrived race condition.
 
It cannot be optimized away.
"Öö Tiib" <ootiib@hot.ee>: Oct 01 11:20PM -0700

On Tuesday, 2 October 2018 08:12:11 UTC+3, Chris M. Thomasson wrote:
> and stores with relaxed memory ordering. There is no undefined behavior
> wrt the logic that is generating the contrived race condition.
 
> It cannot be optimized away.
 
May be in current standard. Have you noticed the cult of undefined
and inquisition of behavior in committees? Those can simply declare
techniques ill-formed because of being "arcane" witchcraft.
 
http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_active.html#2118
----- quote (capitalization mine)
2118. Stateful metaprogramming via friend injection
Section: 17.7.5 [temp.inject] Status: open Submitter: Richard Smith
Date: 2015-04-27
 
Defining a friend function in a template, then referencing that function
later provides a means of capturing and retrieving metaprogramming state.
This TECHNIQUE IS ARCANE and should be made ill-formed.
 
Notes from the May, 2015 meeting:
 
CWG agreed that such techniques should be ill-formed, although the
mechanism for prohibiting them is as yet undetermined.
----- end quote
 
Both gcc and clang have by now obeyed and the constexpr counters give
vague warnings about friend functions and do not work anymore.
"Chris M. Thomasson" <invalid_chris_thomasson@invalid.invalid>: Oct 01 11:44PM -0700

On 10/1/2018 11:20 PM, Öö Tiib wrote:
>> wrt the logic that is generating the contrived race condition.
 
>> It cannot be optimized away.
 
> May be in current standard.
 
It better not be! A lot of algorithms use simple atomic loads and stores
with relaxed memory ordering.
 
 
> Have you noticed the cult of undefined
> and inquisition of behavior in committees? Those can simply declare
> techniques ill-formed because of being "arcane" witchcraft.
 
It is simply using atomic loads and stores along with relaxed memory
order. The atomics should not be optimized away. They better not be, or
else it would ruin things. It would seem to mess around with other
algorithms as well.
 
 
 
> ----- end quote
 
> Both gcc and clang have by now obeyed and the constexpr counters give
> vague warnings about friend functions and do not work anymore.
 
All of the atomic loads and stores in an algorithm should be intact,
damn it.
Elephant Man <conanospamic@gmail.com>: Oct 01 10:06PM

Article d'annulation émis par un modérateur JNTP via Nemo.
Elephant Man <conanospamic@gmail.com>: Oct 01 10:06PM

Article d'annulation émis par un modérateur JNTP via Nemo.
Elephant Man <conanospamic@gmail.com>: Oct 01 10:07PM

Article d'annulation émis par un modérateur JNTP via Nemo.
Chris Vine <chris@cvine--nospam--.freeserve.co.uk>: Oct 01 11:04PM +0100

On Mon, 1 Oct 2018 14:26:50 -0700
> there source code inside the zip file are mersenne.pas and
> splitmix64.pas, and they are powerful, please look at them, and you can
> port them to C++.
 
The fact that your crap software that no one is interested in can be
ported to C++ does not make it on topic on this newsgroup. This
newsgroup is concerned with the C++ language not your second rate
algorithms, your mental illness or your inability to control yourself.
 
Please feel free to post to this newsgroup about your software when you
have ported it to C++. Otherwise control yourself, take your
medications and shut up.
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: