Wednesday, September 30, 2020

Digest for comp.lang.c++@googlegroups.com - 14 updates in 1 topic

olcott <NoOne@NoWhere.com>: Sep 29 07:12PM -0500

On 9/29/2020 4:53 PM, David Brown wrote:
> if the statements in the body are simple assignments like the ones
> above, or even some function calls, then the compiler can re-arrange
> them because there is no (defined) way for the program to see a difference.
 
Okay great. How it an initialization different than an assignment under
the covers in the machine code?
 
--
Copyright 2020 Pete Olcott
David Brown <david.brown@hesbynett.no>: Sep 30 08:26AM +0200

On 30/09/2020 02:12, olcott wrote:
>> difference.
 
> Okay great. How it an initialization different than an assignment under
> the covers in the machine code?
 
I hope I don't need to explain to you the difference in C++ between a
constructor and an assignment operator? It can certainly be the case
for simple types that the generated assembly code is the same for both
operations - I'd expect that in this case.
Ralf Goertz <me@myprovider.invalid>: Sep 30 10:29AM +0200

Am Tue, 29 Sep 2020 23:53:44 +0200
> above, or even some function calls, then the compiler can re-arrange
> them because there is no (defined) way for the program to see a
> difference.
 
Why is it then that in
 
struct X {
int i;
float z;
X(float z_, int i_) : z(z_), i(i_) {}
};
 
int main() {
X x(3.2,4);
}
 
with g++ -Wall I get:
ini.cc: In constructor 'X::X(float, int)':
ini.cc:3:11: warning: 'X::z' will be initialized after [-Wreorder]
3 | float z;
| ^
ini.cc:2:9: warning: 'int X::i' [-Wreorder]
2 | int i;
| ^
ini.cc:4:5: warning: when initialized here [-Wreorder]
4 | X(float z_, int i_) : z(z_), i(i_) {}
| ^
 
What is the point of that warning? If the compiler can (in this case
actually) initialize in any order why can't (or shouldn't) I write it in
any order? Even if the initialization of one member "foo" requires the
other member "bar" to be initialized first the compiler can figure out
the necessary order. And foo itself can't know anything about the the
position of bar in the struct so that it would matter, right?
David Brown <david.brown@hesbynett.no>: Sep 30 12:04PM +0200

On 30/09/2020 10:29, Ralf Goertz wrote:
> other member "bar" to be initialized first the compiler can figure out
> the necessary order. And foo itself can't know anything about the the
> position of bar in the struct so that it would matter, right?
 
You have to understand the difference between the semantics of the
language, and the code generated by the compiler.
 
The language rules say that for member initialisation like this, the
order follows the order of declaration in the class, not the order in
the initialisation clause. gcc helpfully warns you if the
initialisation clause does not match, because there you have code that
looks different from its actual meaning.
 
Within a constructor body, the order of assignment (not initialisation)
follows the order of the statements.
 
 
When generating object code for all this, a compiler can re-arrange
things in all sorts of ways to get more efficient object code, as long
as the result is identical in terms of the observable behaviour for the
program. Since C++ code cannot access either "i" or "z" within an X
object before the creation is finished, it doesn't matter which one is
/actually/ initialised first in the object code. In your example, since
"x" is not used, the compiler won't bother creating the object at all.
If you instead have:
 
X foo() {
X x(3.2,4);
return x;
}
 
the compiler (in my tests) will generate a single 64-bit load
instruction - it initialises both fields at the same time.
 
But if the fields had been more complex types, with their own
non-trivial constructors, the order /could/ matter and the compiler
would generate code that ordered initialisation according to the rules
of the language.
Paavo Helde <myfirstname@osa.pri.ee>: Sep 30 04:04PM +0300

30.09.2020 11:29 Ralf Goertz kirjutas:
> 4 | X(float z_, int i_) : z(z_), i(i_) {}
> | ^
 
> What is the point of that warning?
 
I have seen this warning many times after code refactoring and it's one
of the most annoying ones. The compiler is trying to be too smart, or
not smart enough. It sees that you have written the mem-initializers in
the wrong order, and assumes you are stupid and you think this is the
order in which they are initialized. Thus it "helpfully" informs you
that this is not so.
 
If the compiler were a bit smarter, it would see these initializations
do not depend on each other and therefore it does not matter at all in
which order they get initialized, so there is no need for a warning.
 
Alternatively, if the compiler trusted the user to know the language
rules, there would be no need for a warning if the user writes the
initializers in a random order, as the user obviously trusts the
compiler for putting them into correct order automatically.
 
 
 
> any order? Even if the initialization of one member "foo" requires the
> other member "bar" to be initialized first the compiler can figure out
> the necessary order.
 
The compiler is not allowed to figure out the "correct" order, it has to
follow the declaration order.
 
I guess it's not clear for everybody why language rules are written the
way they are. The reason is simple, the members need to be destructed in
the opposite order of creation, regardless of by which constructor or in
which TU the object was constructed, and the declaration order is the
only order the destructor is guaranteed to know about.
 
And yes, sometimes the member initialization order is important. For
example, if a class contains a std::thread as a member, working with the
same object, then the thread member must be the last one declared,
otherwise the thread may start running before the main object is fully
constructed. Good luck for having the compiler to try to figure out such
things automatically!
Ralf Goertz <me@myprovider.invalid>: Sep 30 03:15PM +0200

Am Wed, 30 Sep 2020 12:04:19 +0200
> the initialisation clause. gcc helpfully warns you if the
> initialisation clause does not match, because there you have code that
> looks different from its actual meaning.
 
Okay, but in the declaration you declare and nothing else. Why does it
matter in the initialzation phase that you had a different order when
you declared the class. Of course, if the initialization of (in my
example) z depended on i like in
 
X(float z_, int i_) : z(z_+i), i(i_) {}
 
then the order of initialization matters. So in this case gcc could warn
about the usage of uninitialized members or so. But I still couldn't
care less, whether z was *declared* before i or vice versa.
 
> non-trivial constructors, the order /could/ matter and the compiler
> would generate code that ordered initialisation according to the rules
> of the language.
 
Can you give an example for that that would not be covered by the usage
of uninitialzed members? And even if you can why isn't then the order of
initialization the one I should care about. What I mean is why should I
or the compiler care that the declaration order is different. Is that
important in any way other than that it differs and the language says it
shouldn't?
James Kuyper <jameskuyper@alumni.caltech.edu>: Sep 30 09:31AM -0400

On 9/29/20 4:51 PM, David Brown wrote:
 
> And as always, the compiler can re-arrange that into any order it wants
> if the difference can't be seen by code. (That applies to both the
> member initialisation part, and the constructor body.)
 
Correct - which means that the issue only comes up when the order in
which the initializations occur does matter. If that is the case, you
can guarantee that the observable results are the same "as if" the
initializations had occurred in the required order, by specifying that
order in the constructor, even if that's not the same as the declaration
order (modulo access controls).
Ralf Goertz <me@myprovider.invalid>: Sep 30 03:41PM +0200

Am Wed, 30 Sep 2020 16:04:39 +0300
> otherwise the thread may start running before the main object is fully
> constructed. Good luck for having the compiler to try to figure out
> such things automatically!
 
But that does only mean that I need to initialize in the correct order.
But the declaration order only matters because the language standards
say so, right?
Manfred <noname@add.invalid>: Sep 30 05:23PM +0200

On 9/30/2020 3:41 PM, Ralf Goertz wrote:
 
> But that does only mean that I need to initialize in the correct order.
> But the declaration order only matters because the language standards
> say so, right?
 
The initialization order is important. And the standard tells you that
in order to control the initialization order you have to arrange the
/declaration/ order accordingly.
 
I would also like to stress that the initialization order is important
to be univocally defined for self-consistency of the object itself, i.e.
for the object to work.
Paavo has already mentioned the destructor requirement of reverse
destruction order (which is both a consistency requirement and a
performance enabler).
More generally member objects may interact with each other, so a
well-defined unique order of initialization is required for this to work.
Since there can be multiple constructors, the natural choice is the
order of declaration, which is guaranteed to be univocal across all
translation units.
Paavo Helde <myfirstname@osa.pri.ee>: Sep 30 07:53PM +0300

30.09.2020 16:41 Ralf Goertz kirjutas:
 
> But that does only mean that I need to initialize in the correct order.
> But the declaration order only matters because the language standards
> say so, right?
 
The requirement that members are deleted in reverse order of creation is
a hard one, this is related to RAII and without that guarantee it would
not be possible to build robust solutions if there are dependencies
between members (and if there are no such dependencies, then the order
of construction is not relevant at all, so no need to worry about that).
 
Thus, knowing the order of construction is needed for the destructor at
least. Theoretically it might be possible to record the order
dynamically in the constructor and store it inside the object, but this
would make the object larger and the destructor code more complicated.
Also, this would imply that different constructors may construct the
members in different order, making their dependencies and the life of
the programmer much more complex.
 
In short, it would introduce some scripting-language-like dynamic
indeterminism into the C++ fundamental data structures, for very little
benefit. I believe nobody wants to go that way. If you really want to
create member objects dynamically in arbitrary order, use e.g.
std::map<std::string, std::any>, it's not that it is not possible to do
such things in C++.
olcott <NoOne@NoWhere.com>: Sep 30 12:24PM -0500

On 9/30/2020 1:26 AM, David Brown wrote:
> constructor and an assignment operator? It can certainly be the case
> for simple types that the generated assembly code is the same for both
> operations - I'd expect that in this case.
 
Someone here seemed to indicate that Initialization may require fewer
assembly language steps than construction.
 
--
Copyright 2020 Pete Olcott
David Brown <david.brown@hesbynett.no>: Sep 30 09:58PM +0200

On 30/09/2020 19:24, olcott wrote:
>> operations - I'd expect that in this case.
 
> Someone here seemed to indicate that Initialization may require fewer
> assembly language steps than construction.
 
Initialisation always involves construction, so that statement does not
make sense.
 
For simple types with trivial construction and assignment, such as those
in examples in this thread, initialisation and assignment will likely
give the same generated code.
David Brown <david.brown@hesbynett.no>: Sep 30 10:02PM +0200

On 30/09/2020 15:15, Ralf Goertz wrote:
 
> Okay, but in the declaration you declare and nothing else. Why does it
> matter in the initialzation phase that you had a different order when
> you declared the class.
 
Why does initialisation order follow declaration order? Because that's
how the language is defined. I don't know /why/ it is defined that way,
but presumably it makes sense in some way.
 
Or do you mean, why does gcc (with the right flags) warn you when your
initialisers don't follow declaration order? That's simpler - as I
said, it is warning you because your code /appears/ to mean an order
that is different from the /actual/ order.
 
>> of the language.
 
> Can you give an example for that that would not be covered by the usage
> of uninitialzed members?
 
Make some classes whose constructors print out a message. Then make a
class containing members of those classes. The order of initialisation
of the members of the big class are then important to the output of the
program.
 
James Kuyper <jameskuyper@alumni.caltech.edu>: Sep 30 05:01PM -0400

On 9/30/20 4:02 PM, David Brown wrote:
> On 30/09/2020 15:15, Ralf Goertz wrote:
>> Am Wed, 30 Sep 2020 12:04:19 +0200
...
 
> Why does initialisation order follow declaration order? Because that's
> how the language is defined. I don't know /why/ it is defined that way,
> but presumably it makes sense in some way.
 
Leaving the order unspecified would cause problems in those cases where
the order matters. Having initialization order follow declaration order
is pretty much the simplest rule that could be defined, and puts the
order fully under the control of the class definition. I doubt that
there's any more complicated reasons than that for this decision.
 
...
> class containing members of those classes. The order of initialisation
> of the members of the big class are then important to the output of the
> program.
 
Ralf: keep in mind that Dave's suggestion of printing merely serves as
an example. Any other shared resource would serve equally well as a
reason why the order would matter.
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.

Digest for comp.programming.threads@googlegroups.com - 6 updates in 6 topics

Amine Moulay Ramdane <aminer68@gmail.com>: Sep 29 11:10AM -0700

Hello,
 
 
The average smartness of arabs is on the rise..
 
I am a white arab and i think i am smart since i have invented many scalable algorithms, and you have to read the following so that
to understand that the average smartness of arabs is on the rise, read the following to notice it:
 
Why IQs Rise When Nations Experience Rapid Economic Development
 
The latest data support these observations by showing that IQs have been rising steadily in countries experiencing the most rapid economic development during the past few decades. As a measure of the interaction between intelligence and modern cognitive stimuli that strengthen capacities for rational classification, quantitative reasoning, etc., a population's average IQ is therefore an indicator of economic modernization and development, not their cause.
 
Read more here:
 
https://evonomics.com/does-your-iq-predict-how-rich-you-will-be/
 
And read the following about arabs:
 
Arab Americans better educated than most in U.S
 
Read more here to notice it:
 
https://www.michigandaily.com/content/arab-americans-better-educated-most-us
 
And read why are Arab American Students Among the Highest GPA Achievers?
 
Read more here:
 
https://www.arabamerica.com/why-arab-american-students-among-highest-gpa-recipients/
 
 
More about arabs..
 
Look at the following video:
 
Prophet Muhammad was white (Sahih Muslim)
 
https://www.youtube.com/watch?v=vGcCCY0XJGE&t=1s
 
 
And look at the following video:
 
Why Many Arab Americans Check 'White' On The US Census
 
https://www.youtube.com/watch?v=D4PwaweUtDw
 
 
More about arabs and arab inventors and arab thinkers..
 
I am a white arab from Morocco living in Canada since year 1989,
and i am an inventor of many scalable algorithms...
 
I am a white arab, and the name "Moulay" in my family name means that i am genetically and culturally descendent of arabs descendent of prophet Mohamed, and i am genetically a descendent of prophet Mohamed, the "Moulay" in my family name means mawlay in arabic and it means
Monsignor, i am called Monsignor because i am white arab genetically and culturally descendent of prophet Mohamed, read about Monsignor here:
 
https://en.wikipedia.org/wiki/Monsignor
 
I am a "white" arab, and as a proof look at this song and
how the arab singers from Saudia Arabia in this video are "whites", i am
also a white arab that looks like them and i am a gentleman that is more civilized, so look at this song in this video:
 
https://www.youtube.com/watch?v=abyHF_zG3ng
 
And about Influence of Arabic and Islamic Philosophy on the Latin West,
read the following:
 
https://plato.stanford.edu/entries/arabic-islamic-influence/
 
And look at this video at how Mesopotamians that were racially arabs were so advanced:
 
Ancient Mesopotamia Inventions and Technology
 
https://www.youtube.com/watch?v=iRG3GZ7zLuc
 
And i think arabs are smart people, Babylonians of Irak were racially arabs, read about them here:
 
3,700-year-old Babylonian tablet rewrites the history of maths - and shows the Greeks did not develop trigonometry
 
Read more here:
 
https://www.telegraph.co.uk/science/2017/08/24/3700-year-old-babylonian-tablet-rewrites-history-maths-could/
 
Also read the following about Arabs:
 
Research: Arab Inventors Make the U.S. More Innovative
 
It turns out that the U.S. is a major home for Arab inventors. In the five-year period from 2009 to 2013, there were 8,786 U.S. patent applications in our data set that had at least one Arab inventor. Of the total U.S. patent applications, 3.4% had at least one Arab inventor, despite the fact that Arab inventors represent only 0.3% of the total population.
 
Read more here:
 
https://hbr.org/2017/02/arab-inventors-make-the-u-s-more-innovative
 
 
Even Steve Jobs the founder of Apple had an arab Syrian immigrant father called Abdul Fattah Jandal.
 
 
Read more here about it:
 
https://www.macworld.co.uk/feature/apple/who-is-steve-jobs-syrian-immigrant-father-abdul-fattah-jandali-3624958/
 
About USA and the brain's power..
 
I have just looked at the following video, look at it carefully:
 
India Is Becoming Its Own Silicon Valley
 
https://www.youtube.com/watch?v=YHVNWtBuDVk
 
Look in the above video at how the smartest people of high-tech
in India are talking about USA, since they are saying that they
don't want to come to USA because of Donald Trump(and this is
related to my writing below), and i think what they are saying is that Donald Trump and his followers are racism towards other groups that are not of there white European group, so i think USA has made a big mistake by electing Donald Trump, and i think that Germany and other European
countries have not to make the same mistake as USA, because read my
my following writing to understand why:
 
More political philosophy about immigration..
 
I am a white arab, and i think i am smart, since i am an inventor
of many scalable algorithms and there implementations, and today
i will speak about an important subject that is immigration..
 
Let's look for example at USA, so read the following from Jonathan Wai that is a Ph.D., it says:
 
"Heiner Rindermann and James Thompson uncovered that the "smart fraction" of a country is quite influential in impacting the performance of that country, for example, its GDP."
 
And it also says the following:
 
""According to recent population estimates, there are about eight Chinese and Indians for every American in the top 1 percent in brains." But consider that the U.S. benefits from the smart fractions of every other country in the world because it continues to serve as a magnet for brainpower, something that is not even factored into these rankings.
 
What these rankings clearly show is America is likely still in the lead in terms of brainpower. And this is despite the fact federal funding for educating our smart fraction is currently zero. Everyone seems worried Americans are falling behind, but this is because everyone is focusing on average and below average people. Maybe it's time we started taking a closer look at the smartest people of our own country."
 
Read more here:
 
https://www.psychologytoday.com/us/blog/finding-the-next-einstein/201312/whats-the-smartest-country-in-the-world
 
So as you are noticing it's immigrants(and there are about eight Chinese and Indians for every American in the top 1 percent in brains) that are making USA a rich country.
 
 
And read also the following to understand more:
 
Why Silicon Valley Wouldn't Work Without Immigrants
 
There are many theories for why immigrants find so much success in tech. Many American-born tech workers point out that there is no shortage of American-born employees to fill the roles at many tech companies. Researchers have found that more than enough students graduate from American colleges to fill available tech jobs. Critics of the industry's friendliness toward immigrants say it comes down to money — that technology companies take advantage of visa programs, like the H-1B system, to get foreign workers at lower prices than they would pay American-born ones.
 
But if that criticism rings true in some parts of the tech industry, it misses the picture among Silicon Valley's top companies. One common misperception of Silicon Valley is that it operates like a factory; in that view, tech companies can hire just about anyone from anywhere in the world to fill a particular role.
 
But today's most ambitious tech companies are not like factories. They're more like athletic teams. They're looking for the LeBrons and Bradys — the best people in the world to come up with some brand-new, never-before-seen widget, to completely reimagine what widgets should do in the first place.
 
"It's not about adding tens or hundreds of thousands of people into manufacturing plants," said Aaron Levie, the co-founder and chief executive of the cloud-storage company Box. "It's about the couple ideas that are going to be invented that are going to change everything."
 
Why do tech honchos believe that immigrants are better at coming up with those inventions? It's partly a numbers thing. As the tech venture capitalist Paul Graham has pointed out, the United States has only 5 percent of the world's population; it stands to reason that most of the world's best new ideas will be thought up by people who weren't born here.
 
If you look at some of the most consequential ideas in tech, you find an unusual number that were developed by immigrants. For instance, Google's entire advertising business — that is, the basis for the vast majority of its revenues and profits, the engine that allows it to hire thousands of people in the United States — was created by three immigrants: Salar Kamangar and Omid Kordestani, who came to the United States from Iran, and Eric Veach, from Canada.
 
But it's not just a numbers thing. Another reason immigrants do so well in tech is that people from outside bring new perspectives that lead to new ideas.
 
Read more here:
 
https://www.nytimes.com/2017/02/08/technology/personaltech/why-silicon-valley-wouldnt-work-without-immigrants.html
 
 
 
Thank you,
Amine Moulay Ramdane.
Amine Moulay Ramdane <aminer68@gmail.com>: Sep 29 10:47AM -0700

Hello..
 
 
Here is more of my thoughts on parallel computing and computing:
 
https://community.idera.com/developer-tools/general-development/f/getit-and-third-party/73117/more-of-my-thoughts-on-parallel-computing-and-computing
 
And here is my thoughts on productivity:
 
https://community.idera.com/developer-tools/general-development/f/getit-and-third-party/73133/about-productivity
 
 
Here is one of my other interesting software project:
 
https://community.idera.com/developer-tools/general-development/f/getit-and-third-party/71852/pldelphi-and-regexp-ere-for-delphi-and-freepascal-64bit-were-just-updated
 
And here is some of my software inventions that i have shared:
 
https://sites.google.com/site/scalable68/scalable-mlock
 
https://sites.google.com/site/scalable68/scalable-reference-counting-with-efficient-support-for-weak-references
 
https://sites.google.com/site/scalable68/scalable-rwlock
 
https://sites.google.com/site/scalable68/scalable-rwlock-that-works-accross-processes-and-threads
 
https://groups.google.com/forum/#!topic/comp.programming.threads/VaOo1WVACgs
 
https://sites.google.com/site/scalable68/an-efficient-threadpool-engine-with-priorities-that-scales-very-well
 
 
You will find more of my software projects in my website here:
 
https://sites.google.com/site/scalable68/
 
 
Thank you,
Amine Moulay Ramdane.
Amine Moulay Ramdane <aminer68@gmail.com>: Sep 29 10:09AM -0700

Hello..
 
 
Here is my new poem: "Time is flowing and walking and running"
 
 
Here is my other new poem of Love that i have just written,
read it listening at the same time at this beautiful song:
 
Cesaria Evora - Mae Velha
 
https://www.youtube.com/watch?v=NhpAbA78IKM
 
 
 
Here is my new poem of Love:
 
 
 
Time is flowing and walking and running
 
But my beautiful heart is always resisting
 
Time is flowing and walking and running
 
But my beautiful love for you is forever staying
 
Time is flowing and walking and running
 
But my beautiful desire for you is "also" always rolling
 
Time is flowing and walking and running
 
But my love for you is a so beautiful King
 
Time is flowing and walking and running
 
Like our love is also forever flowing like a beautiful spring
 
Time is flowing and walking and running
 
But my love is a beautiful ring around your beautiful angel wings
 
Time is flowing and walking and running
 
But my love is a so beautiful offspring
 
Time is flowing and walking and running
 
But our love is like our beautiful God that we are worshiping !
 
 
 
Thank you,
Amine Moulay Ramdane.
Amine Moulay Ramdane <aminer68@gmail.com>: Sep 29 07:44AM -0700

Hello..
 
 
I want to share with you this beautiful song that i love much:
 
Cesaria Evora - Mae Velha
 
https://www.youtube.com/watch?v=NhpAbA78IKM
 
 
 
Thank you,
Amine Moulay Ramdane.
Amine Moulay Ramdane <aminer68@gmail.com>: Sep 29 07:06AM -0700

Hello..
 
 
More explanation about the rule of "work smart and not hard"..
 
I will be more logically rigorous and explain more, so read my logical proof:
 
I have just looked at the following video, i invite you to look at it:
 
People who say "work smart not hard" pretty much always fail | James Gosling and Lex Fridman
 
https://www.youtube.com/watch?v=Jaho2mbaVGM&t=99s
 
Here is James Gosling:
 
https://en.wikipedia.org/wiki/James_Gosling
 
And here is Lex Fridman:
 
https://lexfridman.com/#:~:text=Lex%20Fridman%3A%20I'm%20an,Teaching%3A%20deeplearning.mit.edu
 
 
I think i am a white arab that is smart since i have invented many
scalable algorithms and i say that Lex Fridman and James Gosling in the above video are not smart by saying that "work smart and not hard" pretty much always fail, and notice that Lex Fridman says that
the "not hard" in the rule means lazy, but this is not logically correct, since if the statistical distribution of the strenght and force of the work is normal in the real world , so i have to discern with my fluid intelligence that it is a system that means "work smart and not hard" and it can mean: "work smart and using an average force or strenght", so then it means that this system or rule doesn't pretty much always fail, also we can generalize and say: since the truth of "work smart and not hard pretty much always fail" depends on the statistical distribution(of the strenght and force of the work) in the real world, so we can not generalize and say that the rule of "work smart and not hard" pretty much always fail.
 
 
Here is more logical proof about how i am abstracting smartness to learning..
 
As you have just noticed that i just said the following:
 
---
 
Yet more political philosophy about smartness..
 
I think i am smart, so i will talk more about smartness,
smartness permits to learn, so we can abstract and say that
smartness is like learning, so we can measure smartness by looking at
"quality" of learning, so then if the learning is constrained
by the envirenment it can can hurt the quality of learning and
we can say that we are not smart, but there is still something
about smartness, it is that smartness can be artificial or biologic,
for example when you look at how the Sun causes lightning on earth,
we can then learn from this system of Sun that is causing lightening on earth, and this learning from this system is artificial intelligence and it is smartness , so we can say that our universe also contains such systems that contains smartness of artificial intelligence and we can also say that we can also construct artificial intelligence.
 
--
 
 
So how i am abstracting smartness to learning ?
 
Here is my logical proof:
 
I said the following about fluid intelligence:
 
--
 
Here is my definition of "pattern", since i am using it in
my thoughts of my political philosophy:
 
A pattern is a discernible coherent system based on the intended interrelationship of component parts.
 
So you are understanding that fluid intelligence from genetics
has to discern this coherent system and also extract the rule,
it is also how we are extracting a theorem in mathematics,
it is how works fluid intelligence from genetics.
 
---
 
 
 
So you are noticing that this discerning the coherent system
and extracting the rule(s) is the acts of fluid intelligence,
so since we are discerning the coherent system and extracting
the rules, so it gives after that the "learning", so we can then "abstract" and say that smartness is like learning.
 
 
More precision about more political philosophy about smartness and more..
 
I have just said the following:
 
"So i think we can say that the capacity of being
genetically a good human artist is artificial intelligence and it is then smartness, since i view it as a mechanism or as a system that is artificial intelligence, but we have not to be pessimistic about the social mobility, since it depends on other factors than artifical or biologic human Smartness"
 
I will give more precision: i mean that we have to isolate the part of the brain of being genetically a good human artist, so this part in the brain that comes from genetics of being a good human artist is not smartness that we know of the human brain, so by isolating the part like that we can define it as a mechanism or as a system that is artificial intelligence and we then can say that it is also smartness.
 
Read my following previous thoughts to understand:
 
More political philosophy about smartness and more..
 
Please read below how i am defining being genetically a good human artist..
 
What do you think is smartness ?
 
If i say:
 
2 + 2 = 4
 
So are you capable of seeing smartness ?
 
So if you are smart you will not only look at the equality
of: 2 + 2 = 4, but you will also look at the constraints by
saying that with 2 + 2 = 4 you are not learning much and
by saying that we have to verify if learning is constrained
by the envirenment(like too much limited or so), so now you are understanding what is smartness, and now you are seeing that saying
that smartness is genetical and cultural is not the right abstraction,
because the envirenment can also constrain too much that we can say that
we are not smart.
 
Yet more political philosophy about smartness..
 
I think i am smart, so i will talk more about smartness,
smartness permits to learn, so we can abstract and say that
smartness is like learning, so we can measure smartness by looking at
"quality" of learning, so then if the learning is constrained
by the envirenment it can can hurt the quality of learning and
we can say that we are not smart, but there is still something
about smartness, it is that smartness can be artificial or biologic,
for example when you look at how the Sun causes lightning on earth,
we can then learn from this system of Sun that is causing lightening on earth, and this learning from this system is artificial intelligence and it is smartness , so we can say that our universe also contains such systems that contains smartness of artificial intelligence and we can also say that we can also construct artificial intelligence.
 
So i think we can say that the capacity of being
genetically a good human artist is artificial intelligence and it is then smartness, since i view it as a mechanism or as a system that is artificial intelligence, but we have not to be pessimistic about the social mobility, since it depends on other factors than artificial or biologic human Smartness, and here is what i have just said about it:
 
More political philosophy about social mobility..
 
I have just read the following article:
 
https://www.redpepper.org.uk/social-mobility-is-capitalisms-cover-story/
 
 
So as you are noticing it says:
 
"The prominent sociologist Michael Young claimed that fixed social strata were the regrettable consequence of a meritocratic society, as those who had secured higher positions through merit would use their advantage to ensure their offspring were able to secure similarly superior positions for themselves."
 
 
But he is too pessimistic, since i think that we have to take into account the "context", i think with the current sophistication of internet and the abundance of knowledge on internet, i think this also enhance much more creativity and productivity, and also because of digitalization and by doing business on internet and on the social medias like Facebook and youtube etc. you can "quickly" exponentially grow your number customers and this will enhance much more social mobility, since as i said about Digitalization:
 
Digitalization: Once something goes from physical to digital, it gains
the ability to grow exponentially.
 
So we have not to be pessimistic. And this is related to my following thoughts, read them carefully:
 
https://groups.google.com/g/alt.culture.morocco/c/Nudyb_4QCRU
 
 
Also capitalism switches from linear to exponential growth
 
Read more here:
 
http://parisinnovationreview.com/articles-en/capitalism-switches-from-linear-to-exponential-growth
 
More political philosophy about communism of China and communism..
 
You have to understand that communism of China of today is much more
"modern", i think that it lets many become very rich,
but it taxes the rich much more and that benefits its socialism,
and it demands a greater "loyalty" of the Rich to the communist party of China, and i think that communism China is much more capable because China is a much more bigger and powerful country.
 
Read the following article to notice it:
 
China's Communist Party demands private sector's loyalty as external risks rise
 
https://www.journalpioneer.com/business/reuters/chinas-communist-party-demands-private-sectors-loyalty-as-external-risks-rise-497631/
 
And read the following article to notice it:
 
More taxes for China's super rich will narrow income gap
 
https://www.globaltimes.cn/content/1136002.shtml
 
 
This is why i just said (read below) that communism of China is "useful", i mean it is useful for China and it allows us to see why it is useful and that's useful too !
 
More political philosophy about more interesting subjects..
 
I have just looked at the following video, i invite you to look at it:
 
Jordan Peterson | Full interview
 
https://www.youtube.com/watch?v=1ruwVc0t2c0
 
I think that this Jordan Peterson is not smart by talking as he is talking about Marxism and Feminism, I am a white arab
and i think i am smart since i have invented many scalable algorithms, so i will say that Jordan Peterson is talking about Marxism not correctly, because he is neglecting the "context" of Marxism, since we can say that Marxism is not "generally" a correct ideology, but Marxism can become "useful" in the context of Today world, so i will say that the Today communism of China is "useful", since here is what i have just said about it:
 
---
 
But if you are not smart you will say that communism of China is evil,
but this is not correct because you have to understand the essence of
communism..
 
Here is how to explain it:
 
There is competition and there is collaboration and solidarity,
but competition has a problem, it is that it can monopolize too much,
it is like the problem of monopoly that hurts competition and that hurts quality, so notice that today those that are smart or/and have more money are quickly making too much money with the help of exponential growth of capitalism and exponential progress, so this is a big problem for communism of China, so this is why communism of China of today is not confident with the private sector that is for them having this big problem, and this is why communism of China is not being confident with the West, so this why communism China of today is not wanting to become Democracy.
 
So you can read my following thoughts about the problem of Globalization and the unequal distribution of income and opportunities to understand more(and i am giving a solution to it, so read it carefully):
 
https://groups.google.com/g/alt.culture.morocco/c/wlJu5j1xhPk
 
 
I think that there is a bug in the world system, and it is that we want in capitalism to be competition and competitiveness , this is why so that capitalist countries do attract investment and smart people they have accepted the fact that people make too much money quickly(and you have to understand the context of exponential growth of capitalism and exponential progress), so as you are noticing that this is making communism of China not wanting to become Democracy, or it is making socialism of other countries such as Algeria etc. not wanting to become capitalism.
 
So the West has to solve the problem of Globalization and the unequal distribution of income and opportunities so that to make Marxism much
less relevant.
 
----
 
 
Also notice in the above video that Jordan Peterson is talking about Feminism and saying that he agree with Feminism on equality of opportunities, but he doesn't agree with being equity, but i think he is not thinking correctly since he is too vague, since read for example what i am saying about Meritocracy:
 
Read the following article about Meritocracy from the Atlantic:
 
https://www.theatlantic.com/business/archive/2015/12/meritocracy/418074/
 
So as you notice it says:
 
"The pursuit of meritocracy is more difficult than it appears,"
 
So i think in Meritocracy we can not be strict equality,
so we have to get into the details and into the calculations to tune
it correctly and efficiently so that to make Meritocracy efficient and at the same time less problematic, but we have to notice that Meritocracy is still important.
 
Yet more political philosophy about decentralization..
 
We can say the following:
 
The classical notion of decentralization does not necessarily imply democracy, and an organization may be decentralized without being based on democratic principles.
 
But i ask a smart question of:
 
Can we say that an organization based on democratic principles may be centralized ?
 
Here is my answer:
 
But we can notice that even though decentralization doesn't
necessarily imply Democracy, Democracy is a "kind" of decentralization,
and this kind of decentralization brings efficiency because we can
notice that Democracy needs requirements such as competitive elections and free press, and i think that Democracy is more efficient than
Dictatorship at fighting corruption(and corruption can mean lack of efficiency), read my following thoughts about Democracy and more to understand:
 
https://groups.google.com/g/alt.culture.morocco/c/Nudyb_4QCRU
 
 
But notice in my above link that i am saying that we have to seek like a balance between competition and collaboration, and i think that it is
this new more efficient model of seeking like a balance between competition and collaboration that is the "cause" of bringing decentralization that brings efficiency, and i think that the tendency of our today world is to seek a balance between competition and collaboration.
 
And since i am talking in my following thoughts about the socialist state of Algeria, here is my thoughts about socialism:
 
More political philosophy about socialism..
 
I think that socialism today as a system is a result of an inferior act of human nature that has the tendency to being too much dictatorship or too much fascism, socialism is like measuring individual smartness with only smartness that comes from genetics neglecting smartness that comes from culture, it is like neglecting to reason about some important variables in the system in the context of this Globalization, it is also too much idealism that neglects to see the weaknesses of socialism in the reality and in practice, you will notice that even socialism in Democracy is a bad thing, but socialism of a dictatorship is even worse , since like in optimization in mathematics, since socialism has the
tendency to make the government too big and inefficient, because it is simply socialism, so how to be safe from this act of socialism ? and
since socialism has the tendency to make taxes too much high, so
this is not competitive in the context of this Globalization that needs efficiency of competitiveness, and in dictatorship of Socialism
we are not safe from corruption of the government, and corruption in morality can be lack of efficiency , so how can we "escape" this corruption in a dictatorship? so you are noticing with me that dictatorship is a big problem(read about it below on my writing to understand better),also since socialism is solidarity so it also has the tendency to help too much the national companies that are deficient and this not good and this even engender too much debt and this is not good in the context of this Globalization that needs competitiveness, and let us take a look at my writing about socialism in Democracy, it is not even in dictatorship, here
Amine Moulay Ramdane <aminer68@gmail.com>: Sep 29 06:44AM -0700

Hello,
 
 
More political philosophy about the rule of "work smart and not hard"..
 
I will be more logically rigorous, so read my logical proof:
 
I have just looked at the following video, i invite you to look at it:
 
People who say "work smart not hard" pretty much always fail | James Gosling and Lex Fridman
 
https://www.youtube.com/watch?v=Jaho2mbaVGM&t=99s
 
Here is James Gosling:
 
https://en.wikipedia.org/wiki/James_Gosling
 
And here is Lex Fridman:
 
https://lexfridman.com/#:~:text=Lex%20Fridman%3A%20I'm%20an,Teaching%3A%20deeplearning.mit.edu
 
 
I think i am a white arab that is smart since i have invented many
scalable algorithms and i say that Lex Fridman and James Gosling in the above video are not smart by saying that "work smart and not hard" pretty much always fail, since the truth of "work smart and not hard pretty much always fail" depends on the statistical distribution(of the strenght and force of the work) in the real world, so we can not generalize and say that the rule of "work smart and not hard" pretty much always fail.
 
 
Here is more logical proof about how i am abstracting smartness to learning..
 
As you have just noticed that i just said the following:
 
---
 
Yet more political philosophy about smartness..
 
I think i am smart, so i will talk more about smartness,
smartness permits to learn, so we can abstract and say that
smartness is like learning, so we can measure smartness by looking at
"quality" of learning, so then if the learning is constrained
by the envirenment it can can hurt the quality of learning and
we can say that we are not smart, but there is still something
about smartness, it is that smartness can be artificial or biologic,
for example when you look at how the Sun causes lightning on earth,
we can then learn from this system of Sun that is causing lightening on earth, and this learning from this system is artificial intelligence and it is smartness , so we can say that our universe also contains such systems that contains smartness of artificial intelligence and we can also say that we can also construct artificial intelligence.
 
--
 
 
So how i am abstracting smartness to learning ?
 
Here is my logical proof:
 
I said the following about fluid intelligence:
 
--
 
Here is my definition of "pattern", since i am using it in
my thoughts of my political philosophy:
 
A pattern is a discernible coherent system based on the intended interrelationship of component parts.
 
So you are understanding that fluid intelligence from genetics
has to discern this coherent system and also extract the rule,
it is also how we are extracting a theorem in mathematics,
it is how works fluid intelligence from genetics.
 
---
 
 
 
So you are noticing that this discerning the coherent system
and extracting the rule(s) is the acts of fluid intelligence,
so since we are discerning the coherent system and extracting
the rules, so it gives after that the "learning", so we can then "abstract" and say that smartness is like learning.
 
 
More precision about more political philosophy about smartness and more..
 
I have just said the following:
 
"So i think we can say that the capacity of being
genetically a good human artist is artificial intelligence and it is then smartness, since i view it as a mechanism or as a system that is artificial intelligence, but we have not to be pessimistic about the social mobility, since it depends on other factors than artifical or biologic human Smartness"
 
I will give more precision: i mean that we have to isolate the part of the brain of being genetically a good human artist, so this part in the brain that comes from genetics of being a good human artist is not smartness that we know of the human brain, so by isolating the part like that we can define it as a mechanism or as a system that is artificial intelligence and we then can say that it is also smartness.
 
Read my following previous thoughts to understand:
 
More political philosophy about smartness and more..
 
Please read below how i am defining being genetically a good human artist..
 
What do you think is smartness ?
 
If i say:
 
2 + 2 = 4
 
So are you capable of seeing smartness ?
 
So if you are smart you will not only look at the equality
of: 2 + 2 = 4, but you will also look at the constraints by
saying that with 2 + 2 = 4 you are not learning much and
by saying that we have to verify if learning is constrained
by the envirenment(like too much limited or so), so now you are understanding what is smartness, and now you are seeing that saying
that smartness is genetical and cultural is not the right abstraction,
because the envirenment can also constrain too much that we can say that
we are not smart.
 
Yet more political philosophy about smartness..
 
I think i am smart, so i will talk more about smartness,
smartness permits to learn, so we can abstract and say that
smartness is like learning, so we can measure smartness by looking at
"quality" of learning, so then if the learning is constrained
by the envirenment it can can hurt the quality of learning and
we can say that we are not smart, but there is still something
about smartness, it is that smartness can be artificial or biologic,
for example when you look at how the Sun causes lightning on earth,
we can then learn from this system of Sun that is causing lightening on earth, and this learning from this system is artificial intelligence and it is smartness , so we can say that our universe also contains such systems that contains smartness of artificial intelligence and we can also say that we can also construct artificial intelligence.
 
So i think we can say that the capacity of being
genetically a good human artist is artificial intelligence and it is then smartness, since i view it as a mechanism or as a system that is artificial intelligence, but we have not to be pessimistic about the social mobility, since it depends on other factors than artificial or biologic human Smartness, and here is what i have just said about it:
 
More political philosophy about social mobility..
 
I have just read the following article:
 
https://www.redpepper.org.uk/social-mobility-is-capitalisms-cover-story/
 
 
So as you are noticing it says:
 
"The prominent sociologist Michael Young claimed that fixed social strata were the regrettable consequence of a meritocratic society, as those who had secured higher positions through merit would use their advantage to ensure their offspring were able to secure similarly superior positions for themselves."
 
 
But he is too pessimistic, since i think that we have to take into account the "context", i think with the current sophistication of internet and the abundance of knowledge on internet, i think this also enhance much more creativity and productivity, and also because of digitalization and by doing business on internet and on the social medias like Facebook and youtube etc. you can "quickly" exponentially grow your number customers and this will enhance much more social mobility, since as i said about Digitalization:
 
Digitalization: Once something goes from physical to digital, it gains
the ability to grow exponentially.
 
So we have not to be pessimistic. And this is related to my following thoughts, read them carefully:
 
https://groups.google.com/g/alt.culture.morocco/c/Nudyb_4QCRU
 
 
Also capitalism switches from linear to exponential growth
 
Read more here:
 
http://parisinnovationreview.com/articles-en/capitalism-switches-from-linear-to-exponential-growth
 
More political philosophy about communism of China and communism..
 
You have to understand that communism of China of today is much more
"modern", i think that it lets many become very rich,
but it taxes the rich much more and that benefits its socialism,
and it demands a greater "loyalty" of the Rich to the communist party of China, and i think that communism China is much more capable because China is a much more bigger and powerful country.
 
Read the following article to notice it:
 
China's Communist Party demands private sector's loyalty as external risks rise
 
https://www.journalpioneer.com/business/reuters/chinas-communist-party-demands-private-sectors-loyalty-as-external-risks-rise-497631/
 
And read the following article to notice it:
 
More taxes for China's super rich will narrow income gap
 
https://www.globaltimes.cn/content/1136002.shtml
 
 
This is why i just said (read below) that communism of China is "useful", i mean it is useful for China and it allows us to see why it is useful and that's useful too !
 
More political philosophy about more interesting subjects..
 
I have just looked at the following video, i invite you to look at it:
 
Jordan Peterson | Full interview
 
https://www.youtube.com/watch?v=1ruwVc0t2c0
 
I think that this Jordan Peterson is not smart by talking as he is talking about Marxism and Feminism, I am a white arab
and i think i am smart since i have invented many scalable algorithms, so i will say that Jordan Peterson is talking about Marxism not correctly, because he is neglecting the "context" of Marxism, since we can say that Marxism is not "generally" a correct ideology, but Marxism can become "useful" in the context of Today world, so i will say that the Today communism of China is "useful", since here is what i have just said about it:
 
---
 
But if you are not smart you will say that communism of China is evil,
but this is not correct because you have to understand the essence of
communism..
 
Here is how to explain it:
 
There is competition and there is collaboration and solidarity,
but competition has a problem, it is that it can monopolize too much,
it is like the problem of monopoly that hurts competition and that hurts quality, so notice that today those that are smart or/and have more money are quickly making too much money with the help of exponential growth of capitalism and exponential progress, so this is a big problem for communism of China, so this is why communism of China of today is not confident with the private sector that is for them having this big problem, and this is why communism of China is not being confident with the West, so this why communism China of today is not wanting to become Democracy.
 
So you can read my following thoughts about the problem of Globalization and the unequal distribution of income and opportunities to understand more(and i am giving a solution to it, so read it carefully):
 
https://groups.google.com/g/alt.culture.morocco/c/wlJu5j1xhPk
 
 
I think that there is a bug in the world system, and it is that we want in capitalism to be competition and competitiveness , this is why so that capitalist countries do attract investment and smart people they have accepted the fact that people make too much money quickly(and you have to understand the context of exponential growth of capitalism and exponential progress), so as you are noticing that this is making communism of China not wanting to become Democracy, or it is making socialism of other countries such as Algeria etc. not wanting to become capitalism.
 
So the West has to solve the problem of Globalization and the unequal distribution of income and opportunities so that to make Marxism much
less relevant.
 
----
 
 
Also notice in the above video that Jordan Peterson is talking about Feminism and saying that he agree with Feminism on equality of opportunities, but he doesn't agree with being equity, but i think he is not thinking correctly since he is too vague, since read for example what i am saying about Meritocracy:
 
Read the following article about Meritocracy from the Atlantic:
 
https://www.theatlantic.com/business/archive/2015/12/meritocracy/418074/
 
So as you notice it says:
 
"The pursuit of meritocracy is more difficult than it appears,"
 
So i think in Meritocracy we can not be strict equality,
so we have to get into the details and into the calculations to tune
it correctly and efficiently so that to make Meritocracy efficient and at the same time less problematic, but we have to notice that Meritocracy is still important.
 
Yet more political philosophy about decentralization..
 
We can say the following:
 
The classical notion of decentralization does not necessarily imply democracy, and an organization may be decentralized without being based on democratic principles.
 
But i ask a smart question of:
 
Can we say that an organization based on democratic principles may be centralized ?
 
Here is my answer:
 
But we can notice that even though decentralization doesn't
necessarily imply Democracy, Democracy is a "kind" of decentralization,
and this kind of decentralization brings efficiency because we can
notice that Democracy needs requirements such as competitive elections and free press, and i think that Democracy is more efficient than
Dictatorship at fighting corruption(and corruption can mean lack of efficiency), read my following thoughts about Democracy and more to understand:
 
https://groups.google.com/g/alt.culture.morocco/c/Nudyb_4QCRU
 
 
But notice in my above link that i am saying that we have to seek like a balance between competition and collaboration, and i think that it is
this new more efficient model of seeking like a balance between competition and collaboration that is the "cause" of bringing decentralization that brings efficiency, and i think that the tendency of our today world is to seek a balance between competition and collaboration.
 
And since i am talking in my following thoughts about the socialist state of Algeria, here is my thoughts about socialism:
 
More political philosophy about socialism..
 
I think that socialism today as a system is a result of an inferior act of human nature that has the tendency to being too much dictatorship or too much fascism, socialism is like measuring individual smartness with only smartness that comes from genetics neglecting smartness that comes from culture, it is like neglecting to reason about some important variables in the system in the context of this Globalization, it is also too much idealism that neglects to see the weaknesses of socialism in the reality and in practice, you will notice that even socialism in Democracy is a bad thing, but socialism of a dictatorship is even worse , since like in optimization in mathematics, since socialism has the
tendency to make the government too big and inefficient, because it is simply socialism, so how to be safe from this act of socialism ? and
since socialism has the tendency to make taxes too much high, so
this is not competitive in the context of this Globalization that needs efficiency of competitiveness, and in dictatorship of Socialism
we are not safe from corruption of the government, and corruption in morality can be lack of efficiency , so how can we "escape" this corruption in a dictatorship? so you are noticing with me that dictatorship is a big problem(read about it below on my writing to understand better),also since socialism is solidarity so it also has the tendency to help too much the national companies that are deficient and this not good and this even engender too much debt and this is not good in the context of this Globalization that needs competitiveness, and let us take a look at my writing about socialism in Democracy, it is not even in dictatorship, here is how it looks like:
 
Now I will talk about some deficiencies of socialism like high taxation..
 
I think that there is a real impact of high taxation of socialism on economic growth, productivity and innovation.
 
Take for example Francois Hollande of the french socialist party,
I do not like the rich had cried Francois Hollande of the socialist party during the election campaign that led to the presidency of France. He went to a confiscatory tax and strangled the middle class with taxes.
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.programming.threads+unsubscribe@googlegroups.com.

Tuesday, September 29, 2020

Digest for comp.lang.c++@googlegroups.com - 2 updates in 1 topic

olcott <NoOne@NoWhere.com>: Sep 29 04:38PM -0500

On 9/29/2020 3:54 PM, David Brown wrote:
 
>>> Sorry, but no. The standard says in [class.base.init]: "Then,
>>> non-static data members are initialized in the order they were
>>> declared in the class definition
 
I proved that the constructor can force the initialization order to be
different than the order they were declared in the class definition.
 
 
--
Copyright 2020 Pete Olcott
David Brown <david.brown@hesbynett.no>: Sep 29 11:53PM +0200

On 29/09/2020 23:38, olcott wrote:
>>>> declared in the class definition
 
> I proved that the constructor can force the initialization order to be
> different than the order they were declared in the class definition.
 
I believe you misunderstand me. /Logically/ the constructor body can
specify a different order than the class definition (though the body
provides assignments, not initialisations - there is a difference). But
if the statements in the body are simple assignments like the ones
above, or even some function calls, then the compiler can re-arrange
them because there is no (defined) way for the program to see a difference.
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.

Fwd: Anger Management



Sent from my iPad

Begin forwarded message:

From: Sharon Kahn <sharon62kahn@gmail.com>
Date: September 29, 2020 at 2:55:03 PM CDT
Subject: Fwd:  Anger Management








Digest for comp.lang.c++@googlegroups.com - 25 updates in 1 topic

"Chris M. Thomasson" <chris.m.thomasson.1@gmail.com>: Sep 28 05:45PM -0700

On 9/28/2020 11:07 AM, Keith Thompson wrote:
> with the resulting pointer doesn't know that it's misaligned. That's
> not much of an issue in x86, where misaligned accesses (usually?) just
> impose a speed penalty,
 
Iirc, misaligned access with a LOCK prefix issues a full bus lock
instead of locking a cache line. Check this out:
 
https://blogs.oracle.com/dave/qpi-quiescence
 
 
 
Richard Damon <Richard@Damon-Family.org>: Sep 28 10:35PM -0400

On 9/28/20 2:31 PM, olcott wrote:
> smallest. Certainly every compiler could compare the need for padding of
> the specified version with the sorted version and then know whether or
> not sorting reduces padding requirements.
 
I believe the standard requires that the order of the members in the
struct has to match the order they are declared in the struct, at least
as long as a access specifier doesn't exist between them.
 
That rule comes from C, without the exception since C doesn't have
access specifiers. As you alluded to elsewhere, allowing rearangement
can cause all sorts of issues with code that makes some otherwise fairly
safe assumptions. I suspect that the rule came out because the early
compilers were smart enough to rearrange, then a lot of code was built
with that assumption, and it became effectively impossible to safely
rearrange so it was defined that it couldn't.
Keith Thompson <Keith.S.Thompson+u@gmail.com>: Sep 28 10:04PM -0700

> can cause all sorts of issues with code that makes some otherwise fairly
> safe assumptions. I suspect that the rule came out because the early
> compilers were smart enough to rearrange, then a lot of code was built
 
Did you mean *weren't* smart enough to rearrange?
 
 
--
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 */
olcott <NoOne@NoWhere.com>: Sep 29 12:34AM -0500

On 9/29/2020 12:04 AM, Keith Thompson wrote:
>> safe assumptions. I suspect that the rule came out because the early
>> compilers were smart enough to rearrange, then a lot of code was built
 
> Did you mean *weren't* smart enough to rearrange?
 
No he meant "were" smart enough, yet this caused problems so they had to
make a standard. It doesn't take much intelligence to sort fields by
size and add a few padding bytes at the end. They (apparently) made it a
standard to not change the specified order to have cross compiler
consistency.
 
 
--
Copyright 2020 Pete Olcott
Jorgen Grahn <grahn+nntp@snipabacken.se>: Sep 29 05:52AM

On Tue, 2020-09-29, Keith Thompson wrote:
>> safe assumptions. I suspect that the rule came out because the early
>> compilers were smart enough to rearrange, then a lot of code was built
 
> Did you mean *weren't* smart enough to rearrange?
 
He must have.
 
>> with that assumption, and it became effectively impossible to safely
>> rearrange so it was defined that it couldn't.
 
If that's what happened, it's a really bad combination: letting bad
code prevent important optimizations. I can see no reason for
portable code to know the struct layout (except perhaps that you can
cast between &foo and &foo.first_element).
 
One could easily imagine each ABI defining struct layout, with
rearrangements, in such a way that waste is minimized.
 
/Jorgen
 
--
// Jorgen Grahn <grahn@ Oo o. . .
\X/ snipabacken.se> O o .
olcott <NoOne@NoWhere.com>: Sep 29 12:59AM -0500

On 9/29/2020 12:52 AM, Jorgen Grahn wrote:
 
> One could easily imagine each ABI defining struct layout, with
> rearrangements, in such a way that waste is minimized.
 
> /Jorgen
 
It makes sense to have the compilers conform to a consistent standard
across compilers.
 
 
--
Copyright 2020 Pete Olcott
"Öö Tiib" <ootiib@hot.ee>: Sep 28 11:23PM -0700

On Tuesday, 29 September 2020 08:53:04 UTC+3, Jorgen Grahn wrote:
> cast between &foo and &foo.first_element).
 
> One could easily imagine each ABI defining struct layout, with
> rearrangements, in such a way that waste is minimized.
 
Clang's -Wpadded warns that there is padding but for some reason fails
to make difference if reordering would help with something or
would just put same padding at end of struct. So even very modern
compiler can easily be relatively dim-witted about the issue.
Tim Woodall <news001@woodall.me.uk>: Sep 29 06:33AM

> enough to know that it needs to do some bitwise operations to isolate
> the required field when two or more fields are loaded by one aligned
> memory access.
 
What about a struct of array members?
 
struct {
short[3]
short
short[3]
short
char[3]
char
char[3]
char
};
 
The Bin Packing Problem is NP-hard. ISTM that the alignment constraints
effectively make optimizing the arrangement of members in the struct an
equivalent problem.
David Brown <david.brown@hesbynett.no>: Sep 29 09:57AM +0200

On 28/09/2020 19:05, olcott wrote:
> really good idea.
 
> Although compilers could be smart enough to do this, they must refrain
> just in case the order of the fields must correpond to disk storage.
 
Compilers /can/ re-arrange struct fields - as long as it does not affect
the observable behaviour of the code. (Writing the struct directly out
to a file would be observable behaviour.) For a while, gcc had an
optimisation that did such re-arrangements, but it got removed as it was
overly complex and unmaintainable in the face of link-time optimisation.
For local structs within a function, compilers certainly can and do
break up and re-arrange fields.
"Öö Tiib" <ootiib@hot.ee>: Sep 29 04:49AM -0700

On Tuesday, 29 September 2020 05:35:36 UTC+3, Richard Damon wrote:
> compilers were smart enough to rearrange, then a lot of code was built
> with that assumption, and it became effectively impossible to safely
> rearrange so it was defined that it couldn't.
 
The problem is that there are two orthogonal considerations: 1) member
order in memory and 2) member initialisation order. Both are expressed
with declaration order in C++. When optimal of one differs from optimal
of other then we do not have semantics to express it.
 
Other a nit ... C++ standard says that members with same access control
are ordered by declaration order (specifiers do not necessarily change
access control).
Richard Damon <Richard@Damon-Family.org>: Sep 29 08:14AM -0400

On 9/29/20 1:04 AM, Keith Thompson wrote:
>> safe assumptions. I suspect that the rule came out because the early
>> compilers were smart enough to rearrange, then a lot of code was built
 
> Did you mean *weren't* smart enough to rearrange?
Yes.
Richard Damon <Richard@Damon-Family.org>: Sep 29 08:28AM -0400

On 9/29/20 1:52 AM, Jorgen Grahn wrote:
 
> One could easily imagine each ABI defining struct layout, with
> rearrangements, in such a way that waste is minimized.
 
> /Jorgen
 
The first big problem is that if you reorder, the reordering MUST be
consistent in every compilation unit, and ideally you want different
compilers to come up with the same result for the same machine.
 
Second, remember that most C code, especially early on want designed to
be totally portable, just fairly portable. It was very common that piece
of most programs would have a lot of assumptions on the machine that was
targeted. If you were doing it well, you tried to isolate most of these
assumptions to just a few files marked with portability comments.
Structs WERE often used to map to hardware registers or file formats,
and the programmer would maybe need to adjust things to map to their
hardware. (Remember, fixed width types are sort of new). Sometimes,
particularly for file (or other communication) formats, you would
realize that your hardware didn't map well to what the format was based
on, and you needed to add a layer to convert to raw bytes (endian issues
or misaligned fields being the biggest example). If compilers could
re-arrange structs, then the odds of being able to match a struct to an
externally defined format drops significantly, forcing going to the low
level techniques.
olcott <NoOne@NoWhere.com>: Sep 29 10:51AM -0500

On 9/29/2020 1:23 AM, Öö Tiib wrote:
> to make difference if reordering would help with something or
> would just put same padding at end of struct. So even very modern
> compiler can easily be relatively dim-witted about the issue.
 
No, apparently not at all. Standards complying compilers are not allowed
to reorder the fields.
 
--
Copyright 2020 Pete Olcott
olcott <NoOne@NoWhere.com>: Sep 29 10:56AM -0500

On 9/29/2020 1:33 AM, Tim Woodall wrote:
> char[3]
> char
> };
 
If we simply assume that the compiler always loads a 32-bit int and then
does bitwise operations to separate the required field the above struct
is already fully packed.
 
> The Bin Packing Problem is NP-hard. ISTM that the alignment constraints
> effectively make optimizing the arrangement of members in the struct an
> equivalent problem.
 
Try and find a concrete example where simply sorting by size and padding
at the end won't work.
 
--
Copyright 2020 Pete Olcott
olcott <NoOne@NoWhere.com>: Sep 29 11:00AM -0500

On 9/29/2020 6:49 AM, Öö Tiib wrote:
> order in memory and 2) member initialisation order. Both are expressed
> with declaration order in C++. When optimal of one differs from optimal
> of other then we do not have semantics to express it.
 
Sure we do. The initialization order can be specified in the contructor.
 
 
--
Copyright 2020 Pete Olcott
Juha Nieminen <nospam@thanks.invalid>: Sep 29 04:05PM

> smallest. Certainly every compiler could compare the need for padding of
> the specified version with the sorted version and then know whether or
> not sorting reduces padding requirements.
 
Btw, this is the reason why I was so disappointed that C++20 designated
initializers have to be specified in the same order as the members have
been declared.
 
In some situations you may want to declare the members in an order that
optimizes space, but specify them in the initialization list in a more
logical order (especially if it's some kind of struct containing all
kinds of settings or other parameters).
 
Also, if you ever eg. change the size of a member and thus need to
change its placement inside the struct, all the initializations will
break (even though that's supposed to be one of the biggest advantages
of designated initializers: The initialization doesn't break if the
order of the members changes.) I suppose getting error messages is
better than the wrong elements being silently initialized, but still,
it would be niced if it just worked.
Juha Nieminen <nospam@thanks.invalid>: Sep 29 04:21PM


> The Bin Packing Problem is NP-hard. ISTM that the alignment constraints
> effectively make optimizing the arrangement of members in the struct an
> equivalent problem.
 
AFAIK the one-dimensional version (which this situation is) is not NP.
You would need at least two structs, and the problem being to distribute
the given elements optimally among them.
 
Alignment constraints effectively make it into a "multiple containers"
situation, because you need to distribute all the elements among these
containing ranges without them spilling over... except it's still not
NP because the elements are always exactly a half, a quarter and
possibly an eighth of the container size.
 
In this situation you can simply always take the largest remaining
element that will fit in the current free space of the current slot.
(There's no optimization conundrum because of that restriction above.)
Paavo Helde <myfirstname@osa.pri.ee>: Sep 29 10:08PM +0300

29.09.2020 19:00 olcott kirjutas:
>> with declaration order in C++. When optimal of one differs from optimal
>> of other then we do not have semantics to express it.
 
> Sure we do. The initialization order can be specified in the contructor.
 
Sorry, but no. The standard says in [class.base.init]: "Then, non-static
data members are initialized in the order they were declared in the
class definition (again regardless of the order of the mem-initializers)."
James Kuyper <jameskuyper@alumni.caltech.edu>: Sep 29 03:28PM -0400

On 9/29/20 3:08 PM, Paavo Helde wrote:
 
> Sorry, but no. The standard says in [class.base.init]: "Then, non-static
> data members are initialized in the order they were declared in the
> class definition (again regardless of the order of the mem-initializers)."
 
Which is immediately followed by "Finally, the compound-statement of the
constructor body is executed." - I presume that he was referring to
initialization occurring inside that compound-statement, which can, in
fact, initialize the members in any desired order.
olcott <NoOne@NoWhere.com>: Sep 29 02:44PM -0500

On 9/29/2020 2:08 PM, Paavo Helde wrote:
 
> Sorry, but no. The standard says in [class.base.init]: "Then, non-static
> data members are initialized in the order they were declared in the
> class definition (again regardless of the order of the mem-initializers)."
 
There is a semantic difference between initializers and constructors.
 
struct Construct
{
int X;
int Y;
int Z;
Construct();
};
 
 
Construct::Construct()
{
printf("Construct::Construct()\n");
Y = 55;
Z = 66;
X = 77;
}
 
--
Copyright 2020 Pete Olcott
Jorgen Grahn <grahn+nntp@snipabacken.se>: Sep 29 08:39PM

On Tue, 2020-09-29, Richard Damon wrote:
 
> The first big problem is that if you reorder, the reordering MUST be
> consistent in every compilation unit, and ideally you want different
> compilers to come up with the same result for the same machine.
 
I thought that was what I addressed in my last paragraph above:
 
>> One could easily imagine each ABI defining struct layout, with
>> rearrangements, in such a way that waste is minimized.
 
E.g. a stable sort of the struct members by size would avoid a lot of
padding, while still being predictable.
 
> Second, remember that most C code, especially early on want designed to
^^^^
I assume that should read ", wasn't".
 
> realize that your hardware didn't map well to what the format was based
> on, and you needed to add a layer to convert to raw bytes (endian issues
> or misaligned fields being the biggest example).
 
I do remember all that, and that's what I feel is "letting bad code
prevent important optimizations". I would have preferred if the
language allowed an ABI to optimize struct layout. People who wanted
to use structs as a convenient way to access bytes in memory could
either (a) know the ABI or (b) use some kind of "packed structs"
extension, like they mostly do today.
 
It's not clear to me as I write this whether the language or the
popular ABIs prevent this ... but I don't really have to know which
one.
 
> re-arrange structs, then the odds of being able to match a struct to an
> externally defined format drops significantly, forcing going to the low
> level techniques.
 
I should probably add that I feel mapping structs onto raw memory is
the /real/ low level technique. I always try to do such things with
portable code, e.g. parsing binary file formats one octet at a time.
That may be a bit slower (I have never tried measuring) but it's portable
and I think it invites fewer bugs too. Including fewer security bugs.
 
/Jorgen
 
--
// Jorgen Grahn <grahn@ Oo o. . .
\X/ snipabacken.se> O o .
David Brown <david.brown@hesbynett.no>: Sep 29 10:48PM +0200

On 29/09/2020 17:51, olcott wrote:
>> compiler can easily be relatively dim-witted about the issue.
 
> No, apparently not at all. Standards complying compilers are not allowed
> to reorder the fields.
 
Compilers are not allowed to make /visible/ reordering of the fields.
But compilers are always allowed to do whatever they want in the way of
optimisations as long as the code appears "as if" it followed the
language rules literally.
David Brown <david.brown@hesbynett.no>: Sep 29 10:51PM +0200

On 29/09/2020 21:28, James Kuyper wrote:
> constructor body is executed." - I presume that he was referring to
> initialization occurring inside that compound-statement, which can, in
> fact, initialize the members in any desired order.
 
And as always, the compiler can re-arrange that into any order it wants
if the difference can't be seen by code. (That applies to both the
member initialisation part, and the constructor body.)
David Brown <david.brown@hesbynett.no>: Sep 29 10:54PM +0200

On 29/09/2020 21:44, olcott wrote:
>   Z = 66;
>   X = 77;
> }
 
The compiler can implement that as though you had written:
 
Construct::Construct()
{
X = 77;
Y = 55;
Z = 66;
printf("Construct::Construct()\n");
}
 
In this case, there is no semantic difference because there is no
observable difference in the behaviour of the program for different
orderings of the initialisers or even the printf() call.
Paavo Helde <myfirstname@osa.pri.ee>: Sep 30 12:17AM +0300

29.09.2020 22:28 James Kuyper kirjutas:
> constructor body is executed." - I presume that he was referring to
> initialization occurring inside that compound-statement, which can, in
> fact, initialize the members in any desired order.
 
This would technically be assignment, not initialization, with the known
drawbacks of "delayed init" (having uninitialized data around for a
while or need to invent dummy placeholder values; also, cannot have
const members).
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.