Sunday, January 26, 2020

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

Tim Rentsch <tr.17687@z991.linuxsc.com>: Jan 21 02:01AM -0800

> 2: simple, unadorned, blunt.
> So I feel that "bald assertion" carries what I meant.
> So it makes me unsure about what you complain.
 
Because I think the phrase doesn't convey the meaning you want
to convey. Or to say that another way, what you think the
phrase says is not how many or most people will read it.
 
(Incidentally, I wouldn't call my comment a complaint, but
that isn't important, just saying fyi.)
Bonita Montero <Bonita.Montero@gmail.com>: Jan 21 12:53PM +0100

>     }
>     else
>         return code & _XABORT_RETRY ? 0 : -1;
return (code & (_XABORT_RETRY | _XABORT_EXPLICIT)) ==
_XABORT_RETRY ? 0 : -1;
> }
 
Otherwise aborted transaction will be returned as retryable.
Bonita Montero <Bonita.Montero@gmail.com>: Jan 18 04:57AM +0100

>>> requires the caller to have a lambda /variable/.
 
>> Why should this be a problem ?
 
> It imposes needless verbosity and bug vectors on the calling code.
 
I'm asking myself what a by-reference lambda should be good for.
Having by-copy-captures disables modification of those captures
if you don't jave a mutable lamda anyway. By-reference-captures
can't also be modified, but just the referenced values. So passing
a lambda by const-reference is useless.
Bonita Montero <Bonita.Montero@gmail.com>: Jan 18 03:49AM +0100

>>> requires the caller to have a lambda /variable/.
 
>> Why should this be a problem ?
 
> It imposes needless verbosity and bug vectors on the calling code.
 
No, that's not bug-prone.
 
>> too large.
 
> No, there is no connection between the way you do cleanup (unsafely, or
> as I propose safely) and the transaction working set.
 
RAII-safeness isn't needed here. There are no resources which might
be allocated in a transaction because a transaction has to be a simple
piece of code whose working-set should fit in the L1-cache.
 
>> I do that with a bool which can hold two states ?
 
> In the same way as your current code which you snipped, which returns
> either 0 or 1.
 
Ok, but your bool-wrapper is stupid.
Paavo Helde <myfirstname@osa.pri.ee>: Jan 20 02:15PM +0200

On 20.01.2020 13:08, Frederick Gotham wrote:
 
> I have multi-posted this to 'comp.lang.c' and 'comp.lang.c++'. I would have gotten more flack if I cross-posted.
 
> I have taken single-threaded code written in Python to calculate hex digits of pi, and I have ported it to C and C++ to compare speed. Both C and C++ versions are faster than the Python version. The C version is about 10% faster than Python. For some reason there is a 20% speed difference between the C and C++ versions, with the C++ one being faster. I don't know why.
 
> All versions use the GNU Multiprecision library (-lgmp).
[...]
> I compiled the C and C++ versions with "-O3 -DNDEBUG". It doesn't make sense to me that the C++ one is faster if the GNU Multiprecision C++ classes are just an interface/wrapper around the C code.
 
> Anyone got any ideas?
 
Code speed depends on many factors. 20% is not so much and might be
specific to your compiler version, hardware and hardware-specific
compiler options. So there are no quick answers.
 
Anyway, one usual source of speed differences is the function inlining.
It might be that by some reason the compiler can inline the C++ Bint *=
operator, but not the C mpz_mul_ui() function call. You can see if this
is the case by studying the generated assembler.
 
My 1-minute googling shows that indeed mpz_mul_ui() is only declared in
gmph.h while Bint *= seems to be both declared and defined in gmpxx.h.
If so, the compiler/linker need to do much more work for getting
functions like mpz_mul_ui() inlined. For that you would probably need to
pass more compiler flags to switch on whole program optimization and
even then it is not sure that it can be done.
 
Even if the C version does not inline the gmp library calls, it is not
certain this is the actual reason of slowdown. Even if it is the reason
with your artificial test case, the slowdown might not appear with real
data. Etc.
 
Also, note that -O3 is not guaranteed to produce fastest code always.
Sometimes it can optimize the wrong thing and produce slower code. For
any case, you should try -O2 as well.
Jorgen Grahn <grahn+nntp@snipabacken.se>: Jan 20 09:32PM

On Mon, 2020-01-20, Chris M. Thomasson wrote:
 
> What about somebody that knows more C than C++? Are they "kind of
> little" because they know C++, but not 100% of it, as in they are not
> expert in every single feature? ;^)
 
He is probably sarcastic, trolling, or both.
 
/Jorgen
 
--
// Jorgen Grahn <grahn@ Oo o. . .
\X/ snipabacken.se> O o .
Mr Flibble <flibbleREMOVETHISBIT@i42.co.uk>: Jan 20 11:52PM

On 20/01/2020 21:58, Chris M. Thomasson wrote:
>>> expert in every single feature? ;^)
 
>> He is probably sarcastic, trolling, or both.
 
> I most likely just consumed a sarcastic sandwich! Humm, tastes like sausages. ;^)
 
https://www.youtube.com/watch?v=9lru1Qxc1l8
 
/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."
Mr Flibble <flibbleREMOVETHISBIT@i42.co.uk>: Jan 20 08:44PM

Stop right where you are! You know the score, pal. If you're not C++, you're little people! #gamedev #coding #codinglife #cpp
 
/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."
"Chris M. Thomasson" <chris.m.thomasson.1@gmail.com>: Jan 20 01:58PM -0800

On 1/20/2020 1:32 PM, Jorgen Grahn wrote:
>> little" because they know C++, but not 100% of it, as in they are not
>> expert in every single feature? ;^)
 
> He is probably sarcastic, trolling, or both.
 
I most likely just consumed a sarcastic sandwich! Humm, tastes like
sausages. ;^)
"Chris M. Thomasson" <chris.m.thomasson.1@gmail.com>: Jan 20 01:01PM -0800

On 1/20/2020 12:44 PM, Mr Flibble wrote:
> Stop right where you are! You know the score, pal. If you're not C++,
> you're little people! #gamedev #coding #codinglife #cpp
 
What about somebody that knows more C than C++? Are they "kind of
little" because they know C++, but not 100% of it, as in they are not
expert in every single feature? ;^)
"Chris M. Thomasson" <chris.m.thomasson.1@gmail.com>: Jan 19 05:14PM -0800


> So i think that programming languages are not designed correctly,
> because the variables that are not local and that are created in the main thread has to be local to the main thread and not accessible
> by the other threads,
 
Not true. One can share data on a threads stack with other threads,
and/or TLS.
 
 
 
Tim Rentsch <tr.17687@z991.linuxsc.com>: Jan 21 02:03AM -0800

Tiib writes:
 
 
>> When T1 is 'int' and T2 is 'base' (aka 'struct base'), which of these
>> categories do you think applies?
 
> T1 is also 'base' so (a) applies.
 
No, it isn't. It appears that either you haven't been listening
or you aren't thinking clearly.
Tim Rentsch <tr.17687@z991.linuxsc.com>: Jan 21 03:47AM -0800


>> In C there is often benefit to have a "stub" type that serves
>> mainly to differentiate the "concrete" types. AFAICT in C++
>> there is not, except perhaps as some sort of aid to the reader.
 
I should elaborate on this. In C, if there is a union with several
structs as members, it's okay to access a member in the common
initial sequence of a struct actually in a union object, __given
only a pointer to the struct__ (assuming the full definition of the
union is visible). In C++, I believe the "common initial sequence"
rule applies only when using the union type as part of the access
expression. The C++ rule is a significantly weaker guarantee than
the C rule. To me it seems to rob the feature of much of its
value, even not counting the incongruity with the C rule. At this
point there are so many differences between C and C++ that it seems
inappropriate to say C is a subset of C++, even just mostly.
 
> API is great for this. C++ can have some issues wrt creating, say
> .so, or .dlls.
 
> A C binding is okay with me.
 
Be warned: the different treatments, by C and by C++, of the
union "special guarantee", might mean that calling through a C
binding may result in undefined behavior in C++, even if the
C code is well-defined by the C standard. It isn't clear to me
what the implications of C++'s rules are in this area, and in
particular whether a C++ implementation may be allowed to make
some assumptions that would not be allowed under the C rules.
I'm sorry I don't have any better advice to offer other than
it would be wise to tread cautiously.
Manfred <noname@add.invalid>: Jan 18 04:22PM +0100

On 1/16/2020 11:11 PM, Öö Tiib wrote:
> It can be tricky for three star programmer to understand what they
> do without such notation OTOH it is unclear if it does help.
> <https://wiki.c2.com/?ThreeStarProgrammer>
 
Note that, as far as I read somewhere, the Hungarian notation was
initially introduced to indicate the "intention or kind" of a variable
or function, which is not that silly of an idea - in fact you always use
the variable name to indicate its purpose, the Hungarian decoration
introduced some kind of naming convention with this respect.
For example, I read it was initially used to identify the coordinate
system some point would belong to (page, print margins, ...) in MS
Office applications.
 
It ended up being misused to encode the variable type in its name, which
is indeed questionable at best, and definitely unfit for generic
programming.
Mr Flibble <flibbleREMOVETHISBIT@i42.co.uk>: Jan 20 05:58PM

> friendly, thoughtful, honest, kind, brave users.
 
> If there are suggestions on how to improve the code or
> documentation, please let me know.
 
Why on Earth do you think I would want to help a bigot who hates all that I stand for? Talk about blinkered.
 
/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."
Mr Flibble <flibbleREMOVETHISBIT@i42.co.uk>: Jan 19 06:17PM

On 19/01/2020 08:55, Christian Gollwitzer wrote:
 
> I think you didn't understand what I was writing:
 
> https://github.com/Ebenezer-group/onwards/commits/master/src/cmw/tiers/cmwA.cc
 
> The commit history doesn't tell me anything. No useful messages.
 
But surely just knowing that all the changes are simply "tweaks" is all you need to know! </sarcasm>
 
/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."
Juha Nieminen <nospam@thanks.invalid>: Jan 20 01:53PM

> std::cout << test;
> }
 
>

No comments: