Friday, November 30, 2018

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

"Alf P. Steinbach" <alf.p.steinbach+usenet@gmail.com>: Nov 30 02:58AM +0100


> One of the comments in this thread:
> https://www.reddit.com/r/cpp/comments/a14o5q/real_world_problems_with_pragma_once/
 
> said that Cray doesn't support pragma once.
 
There is a table in Wikipedia, <url:
https://en.wikipedia.org/wiki/Pragma_once#Portability>.
 
> I know gcc,
> Clang and MSVC do support it. I was wondering if Intel,
> IBM or Oracle compilers support it.
 
Intel yes, IBM yes since version 3.1.1, Oracle yes since dev studio
version 12.5, all according to that table.
 
 
[snip]
 
 
Cheers!,
 
- Alf
woodbrian77@gmail.com: Nov 29 08:06PM -0800

On Thursday, November 29, 2018 at 7:58:45 PM UTC-6, Alf P. Steinbach wrote:
> > IBM or Oracle compilers support it.
 
> Intel yes, IBM yes since version 3.1.1, Oracle yes since dev studio
> version 12.5, all according to that table.
 
I downloaded the Nvidia/Portland Group compiler. It also
handles pragma once. It produces chubby text segments,
though compared to gcc or even clang.
 
 
Brian
Ebenezer Enterprises - In G-d we trust.
http://webEbenezer.net
David Brown <david.brown@hesbynett.no>: Nov 30 08:38AM +0100

On 29/11/18 22:56, Vir Campestris wrote:
>> changing, unless someone complains about it not working with their
>> compiler.
 
> To be fast, and standard compliant, I use both.
 
That may limit the speed advantages of both, depending on the compiler
and on the order you have them. It's not going to make much difference
(either way, you skip compilation - and preprocessing is generally very
fast).
 
I can appreciate that some people think "#pragma once" is neater than
include guards, and so choose to use it. And I can appreciate people
choosing include guards, as they are standard and supported everywhere.
But using both kind of defeats the purpose - it combines the
disadvantages of both methods.
 
"Öö Tiib" <ootiib@hot.ee>: Nov 30 01:46AM -0800


> I downloaded the Nvidia/Portland Group compiler. It also
> handles pragma once. It produces chubby text segments,
> though compared to gcc or even clang.
 
It is hard to find conforming compilers that do not support
pragma once.
 
There can be issue with projects where there are copies of
same header; when more than one of those end up included
to same cpp file then pragma once and include guards
handle it differently.
Bonita Montero <Bonita.Montero@gmail.com>: Nov 30 05:45PM +0100

> I think "#pragma once" is supported by most compilers, but include
> guards are supported by /all/ compilers.  I would expect performance
> of them to be very similar - ...
 
Thinking about the efficiency of #pragma once or include-guards is
idiotic.
Vir Campestris <vir.campestris@invalid.invalid>: Nov 30 09:47PM

On 30/11/2018 16:45, Bonita Montero wrote:
> Thinking about the efficiency of #pragma once or include-guards is
> idiotic.
 
When your compile cycle takes 35 minutes using Icecream and a pool of a
couple of hundred CPUs you care.
 
Andy
Vir Campestris <vir.campestris@invalid.invalid>: Nov 30 09:49PM

On 30/11/2018 09:46, Öö Tiib wrote:
> same header; when more than one of those end up included
> to same cpp file then pragma once and include guards
> handle it differently.
 
I can't think of any reasonable case where they would.
 
(unreasonable? two files with the same guard name??)
 
Andy
"Alf P. Steinbach" <alf.p.steinbach+usenet@gmail.com>: Nov 30 10:59PM +0100

On 30.11.2018 22:47, Vir Campestris wrote:
>> idiotic.
 
> When your compile cycle takes 35 minutes using Icecream and a pool of a
> couple of hundred CPUs you care.
 
Did you try Lakos external include guards?
 
Cheers!,
 
- Alf
"Alf P. Steinbach" <alf.p.steinbach+usenet@gmail.com>: Nov 30 11:12PM +0100

On 30.11.2018 22:49, Vir Campestris wrote:
>> handle it differently.
 
> I can't think of any reasonable case where they would.
 
> (unreasonable? two files with the same guard name??)
 
Generally a local file can be identified by volume id and file id within
the volume. This means that with a compiler with some smarts in its file
identification scheme a /copy/ B of a local file A will not be viewed as
the same file as A. One hypothetical way that that could happen is when
a 3rd party library L that you're using bundles a library M header it
uses, when you're also using library M directly.
 
A second scenario can be when it's difficult to identify a file residing
on a different host on the local network, or even out in the cloud.
 
However, in the Reddit thread referred to by Brian, AFAICS nobody
reported ever actually having had problems with `#pragma once`, but some
reported having had problems with ordinary include guards, in particular
stemming from the not uncommon technique of copy-and-modify programming.
 
 
Cheers!,
 
- Alf
Pavel <pauldontspamtolk@removeyourself.dontspam.yahoo>: Nov 30 02:18PM -0500

Chris M. Thomasson wrote:
> }
> _____________________________
 
> Will post more info sometime tomorrow.
 
Chris, do you have a use case? Your approach of ordering multiple
resources that need locking in some global order (along with alternative
optimistic algorithms) has been successfully used by DBMS s for years to
transactionally alter multiple rows (or records or sets etc for
non-relational DBMSs) for concurrent transactions so the algorithm
itself is sound.
 
With regard to mutexes in a multi-threaded program, however, I cannot
recall when I saw a necessity to simultaneously lock more than one mutex
(I saw code that did it but always in the context where I would either
refactor it to not do it or at least wanted to refactor it so). It might
certainly be that my experience is skewed so I am curious to see a use case.
Melzzzzz <Melzzzzz@zzzzz.com>: Nov 30 08:01PM

> (I saw code that did it but always in the context where I would either
> refactor it to not do it or at least wanted to refactor it so). It might
> certainly be that my experience is skewed so I am curious to see a use case.
Refactor this:
{
AutoLock<Mutex> l(lstSvcM_);
AutoLock<Mutex> ll(availM_);
AutoLock<Mutex> guard(rtlock);
if(!lstSvc_.empty())
{
s= lstSvc_.front();
lstSvc_.pop_front();
} else if((running_threads < 100 || threadsAvail_ > 3) && !lstSvcLow_.empty()) {
s = lstSvcLow_.front();
lstSvcLow_.pop_front();
} else {
more = false;
s=0;
continue;
}
}
 
 
--
press any key to continue or any other to quit...
Pavel <pauldontspamtolk@removeyourself.dontspam.yahoo>: Nov 30 04:31PM -0500

Melzzzzz wrote:
> continue;
> }
> }
 
What does "this" compute and why?
woodbrian77@gmail.com: Nov 30 11:03AM -0800


> Brian
> Ebenezer Enterprises - Enjoying programming again.
> http://webEbenezer.net
 
First, the link above for wrappers.hh has changed. The new link is
https://github.com/Ebenezer-group/onwards/blob/master/src/cmw/Buffer.hh
 
Some may make fun of on-line code generation, but today
I'm trying to install the Intel C++ compiler. I got
"Checking the prerequisites. It can take several minutes.
Please wait...". That was over an hour ago and nothing has
happened. I'm sure there are hundreds of others across the
world who are having problems installing C++ compilers.
Some of them have realized they have a problem, but others
haven't even realized that their install is faulty yet.
 
On-line code generation minimizes the software that you have
to download/build/maintain, thereby avoiding most of these
install problems.
 
 
Brian
Ebenezer Enterprises
http://webEbenezer.net
wyniijj@gmail.com: Nov 29 05:18PM -0800

Öö Tiib於 2018年11月29日星期四 UTC+8下午9時25分08秒寫道:
> > 'for fun' looked to me (much less insightful).
 
> The constexpr function of C++11 can contain only one, return,
> statement. That is clearly too limiting.
 
That's another helpful piece of information for me.
By the way, is the function definition
constexpr size_t slen(const char* cstr) { return ::strlen(cstr); }
correct in c++11 (or c++14,c++17)?
 
> So it is developer who should choose what tool to use
> for what task. Python is better tool for some situations,
> C++ for other situations.
 
We were using the same words 'user/developer' in different context.
with 'user' I meant (c++) language user
with 'developer' I meant (c++) language developer
Because I used to encounter c++ language developers here in this
forum, or people who speak like c++ language developers. I thought
you might be a c++ language developer too, or at least one devoted
to the development of c++ language.
 
I sensed you recommend c++17. The major concern is a part of my
program require nearly exaustive accompanying test codes. If c++17
is adopted, I have to skip/ignore those new things added sine c++11,
I am not sure this skip/ignore-ness is safe, or proper.
 
By the way, thanks to Scott Lurndal who explained 'sub-par'
"Öö Tiib" <ootiib@hot.ee>: Nov 30 01:11AM -0800

> > > Öö Tiib於 2018年11月28日星期三 UTC+8下午9時13分36秒寫道:
> > > > On Wednesday, 28 November 2018 02:09:10 UTC+2, wyn...@gmail.com wrote:
> > > > > Öö Tiib於 2018年11月28日星期三 UTC+8上午12時28分20秒寫道:
 
snipping a bit.
 
> By the way, is the function definition
> constexpr size_t slen(const char* cstr) { return ::strlen(cstr); }
> correct in c++11 (or c++14,c++17)?
 
No. Implementation may do strlen compile time as optimization
but C++ committee avoids retrofitting constexpr to library
functions. I don't know the reason of it. People can make
their own in C++11 with recursion:
 
constexpr
int length(const char* str)
{
return *str ? 1 + length(str + 1) : 0;
}
 
 
> We were using the same words 'user/developer' in different context.
> with 'user' I meant (c++) language user
> with 'developer' I meant (c++) language developer
 
Ok, I misunderstood.
 
> forum, or people who speak like c++ language developers. I thought
> you might be a c++ language developer too, or at least one devoted
> to the development of c++ language.
 
I am programmer. I am not implementer of programming
languages. I have actually only in one project dealt with kind
of self-made scripting language. It convinced me that such
efforts are waste of time. There are too many programming
languages. There are no point to add one more. It is lot easier
and fruitful to fit one of those into any situation.
 
> I sensed you recommend c++17.
 
Actually C++14 improved constexpr in language. The C++17 added
constexpr-compatible class templates (string_view, optional and
variant) to standard library.
 
> program require nearly exaustive accompanying test codes. If c++17
> is adopted, I have to skip/ignore those new things added sine c++11,
> I am not sure this skip/ignore-ness is safe, or proper.
 
I do not understand that logic. How difficulties with C++17
follow from tests? Tests are normal with any toolset and there
are AFAIK nothing in C++17 that makes testing harder. It is even
easier to migrate to newer compiler when there are tests since
those help to discover cases when some incompatibility or
defect starts to manifest itself.
wyniijj@gmail.com: Nov 30 06:02AM -0800

Öö Tiib於 2018年11月30日星期五 UTC+8下午5時12分05秒寫道:
> {
> return *str ? 1 + length(str + 1) : 0;
> }
 
Brilliant solution! (or resolution made by c++11)
 
> easier to migrate to newer compiler when there are tests since
> those help to discover cases when some incompatibility or
> defect starts to manifest itself.
 
I mean manually writting test cases for, for instance, all the
'new words' that can be found in the mentioned webpage for constexpr
https://en.cppreference.com/w/cpp/language/constant_expression
like , including constexpr, lvalue-rvalue*reference, glvalue,
prvalue, immediate function, lambda expression, odr-use , implicit conversion,...
 
Hope you can see that is not an easy job. I had done such things for
pre-c++11. Even today there are still several things inconvenient to
say loudly, e.g. multiple inheritance. I appreciate your expertise
in c++. But if you examine it closely, you might end-up recall the
experience 'waste of time' again. That is what I thought and the
reason hesitate.
"Öö Tiib" <ootiib@hot.ee>: Nov 30 06:50AM -0800

> https://en.cppreference.com/w/cpp/language/constant_expression
> like , including constexpr, lvalue-rvalue*reference, glvalue,
> prvalue, immediate function, lambda expression, odr-use , implicit conversion,...
 
Do you use all that in your code? If you don't then why to test
how compiler handles it? Is your program a parser of C++? Tests
are usually checking if the program (or functions in it) give expected
outputs to test inputs, and not how C++ features work on any kind
of code.
 
> in c++. But if you examine it closely, you might end-up recall the
> experience 'waste of time' again. That is what I thought and the
> reason hesitate.
 
In my programs inheritance is rare, the few inheritance trees are flat
and multiple inheritance is extra rare. The tests are only written if
these few classes with multiple inheritance behave as expected
in contexts where these are used. I do not need tests how multiple
inheritance works in general and in whatever context.
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 - 2 updates in 2 topics

Elephant Man <conanospamic@gmail.com>: Nov 30 09:27AM

Article d'annulation émis par un modérateur JNTP via Nemo.
Horizon68 <horizon@horizon.com>: Nov 29 10:43AM -0800

Hello...
 
 
About wisdom and love..
 
Political philosophy is something really important,
but why am i doing political philosophy ? i am
doing it to be able to "extract" the "architectural" ideas that
are the way to follow and that permit us to walk in the right direction,
you have to be more "serious" about political philosophy, but how am i
extracting those architectural ideas? it is like wisdom
and more smartness in action ! and here again there is something really
important to notice, and it is: you will notice that my writing is
like wisdom , because wisdom is more important to be able to govern,
because with wisdom you are being a higher quality that is more
appropriate to be able to govern ! and why i am making this
"distinction" between wisdom and love ? first because wisdom of
today is like balancing the good and the bad to be able to be the right
perfection, so this makes wisdom superior to love or compassion, and
second, it is because it is related to morality that is perfection at
best as i have proved it, because when you are more naive you will think
that since morality is like perfection so morality is like "mathematics"
or like "efficiency" or it is like a "maximization" of perfection, so it
is like a "corruption" of morality since this can become dangerous, but
i think that this thinking is "inferiority" that doesn't understand
correctly morality of today, and to be able to understand morality you
have to be superiority of wisdom , because morality is perfection at
best , and you have to understand more what is the "at best" of
perfection at best to be able to be more optimistic about morality of
today, this is why
you have to read my following thoughts:
 
 
I am a white arab that is more wise, so you have to understand my way of
doing..
 
What about USA ?
 
You have to be smart, i don't think Donald Trump is a white supremacist
or a neo-nazi, because you have to understand more Donald Trump, Donald
Trump wants also "fairness", you will say that when Donald Trump
says that he wants USA to be great again that's not like fairness, but
i think that you are wrong because Donald Trump wants USA to be great
again and at the same time USA is allowing China (and others) to be
more competitive and to become great ! so thinking of Donald Trump is
like fairness thinking towards China and others ! this is why he has got
into trade war with China, because China was not more "fairness" because
it has not allowed full access to its Market etc. so China was too much
"protectionism", this is why Donald Trump is getting into a trade war
with China to force China to be more fairness, now you know me more that
i am not hating USA because it is an easy process that is not correct
thinking, because also hating our world is an easy process that is not
correct thinking ! because it is immaturity ! so we have to know how to
manage ourselves by first becoming more efficient locally inside a
country and globally around the world ! because you have to understand
me more, i am more "realism" and more "pragmatism" because i am seeing
that USA is also more fairness and efficiency by coming and investing
in Morocco my arab country, and you will ask what are USA investing in
Morocco ? read this and my writing follows:
 
I am a white arab from Moroco, here is US Companies Operating in Morocco:
 
http://heymorocco.com/american-companies-in-morocco.aspx
 
 
I think DXC Technology was not on the list, here it is:
 
Look at the following video about DXC Technology in Morocco:
 
https://www.youtube.com/watch?v=EZ_MyKQ-250
 
 
Read about DXC Technology here:
 
http://www.dxc.technology/
 
 
So as you are noticing USA is also understanding that we have to know
how to work together to be more efficient ! this is why it is working
and investing in other countries such as Morocco !
 
So i think we have to be more optimistic about USA..
 
 
And about wisdom...
 
 
You have to understand my writing..
 
By what are you able to judge wisdom ?
 
By wisdom in itself !
 
So you have to be capable of choosing the right wisdom to be able
to govern, so you have to be able to be "high" quality that is the
right security that is able to choose the right wisdom.
 
 
But what is wisdom ?
 
I said below that wisdom of today is like being moderation, because
wisdom of today has to balance the bad and the good so that to be able
to be the right perfection of perfection at best that is morality,
so is wisdom corruption of morality ? if you are naive you will
say that since it is not good to balance the bad and good, so it
is not morality, but this is "immaturity", because you have to
understand what is morality and what is it to be "decent" morality today
to be able to decide, so read my writing below to understand more about
what is decent morality today and what is morality:
 
Read the rest of my thoughts to understand better:
 
 
About diversity...
 
I said in my previous poem the following:
 
"Our silence cry patience
And our hearts cries love and justice
Like the blue sky
Like the heartbeat of pretty birds
Since we hear the pretty song of the nightingales
And the oasis of the desert tells us about wisdom
Its wisdom that defies the tourmants of the desert
So we walk towards the light
Like a Rainbow
Because my story is multicolored
So I go back to my multicolored land
Because diversity is also wisdom"
 
So notice with me that i want to show that "diversity" is important by
saying also the following:
 
"Because diversity is also wisdom"
 
 
And as you have noticed that there is wisdom and there is love..
 
So is wisdom love or not ? or is wisdom "corruption" of morality ?
 
We have to be capable of political philosophy to understand "wisdom",
wisdom of today is also like a "moderation" that permits the society and
the world to avoid desorder and destruction(read my writing below about
morality to understand better) ! wisdom is something really important,
because when you say "love", it is "inherent" to love that
it is not capable to be a way of governing ! so we have to choose
a more appropriate way of governing ! and i think that wisdom is
also the way, but you have to be capable of political philosophy to
notice that wisdom can not be in contradiction with morality that
is perfection at best, but do we have to be pessismistic about
morality? i think that we have to be more optimistic because
i have explained more what must be the "at best" of perfection at
best that is morality, please read what's following to understand
more what is morality !
 
I will do more political philosophy, please read all my following
thoughts to understand better my thoughts:
 
I think "Flexibility" is also something really important in politics and
management, because nationalism and communism come with some
deficiencies because they lack flexibility, for example communism
still uses Class Struggle that is too violent and that can bring
war and destruction to our humanity, and neo-nazism also uses
Racial Struggle that is too violent that can bring war and destruction
to humanity, and nationalism also use National Struggle against the
others , but the problem of nationalism is that nationalism of today
lacks flexibility too because it is too much nationalism that is not in
accordance with a correct pragmatism or correct realism, nationalism of
today is by analogy as if you are too individualistic, i mean that
nationalism of today is not correct "efficiency", because also
nationalism of today, like the one that resulted from populism, comes
from "fear" of Globalization without
being correct pragmatism and correct efficiency, and i think that's also
lacking of flexibility, because we have to know
more about Globalization, i mean that you have to know how to transcend
your living conditions by being more educated and more skilled and more
efficient and more aware ! this is why i am here to bring my own
thoughts, and this is why i am speaking about how we have today to
get more efficient by working with others globally , not just locally
inside a country, and this is why i said that neo-nazism and white
supremacism lack flexibility too that is needed by efficiency(read below
my writing about neo-nazism and immigration to notice it), now what
about Globalization? read what's follow about Globalization and you will
understand more:
 
About globalization..
 
About populism..
 
I think that populism of USA that has also elected Donald Trump,
and other populism around the world, are like Class "Struggle"
of communism, because this populism is fearing insecurity
of globalization , insecurity that has been created because
this populism of USA have not been able to adapt correctly to
globalization because this populism has to be more skilled and
more educated to be more "competitive" so that to be "successful", also
here is the the solution to populism of USA:
 
First, USA has to adapt and improve quickly in education and health
care, read the following to understand more:
 
The United States ranks 27th in the world for its investments in
education and health care as measurements of its commitment to economic
growth, according to the first-ever scientific study ranking countries
for their levels of human capital.
 
The nation placed just behind Australia (ranked 26th) and just ahead of
Czech Republic (ranked 28th). In contrast, China's ranking of 44th in
2016 represents an increase from its 1990 ranking of 69th.
 
"The decline of human capital in the United States was one of the
biggest surprises in our study," said Dr. Christopher Murray, director
of the Institute for Health Metrics and Evaluation (IHME) at the
University of Washington. "Our findings show the association between
investments in education and health and improved human capital and GDP
-- which policymakers here in the US ignore at their own peril. As the
world economy grows increasingly dependent on digital technology, from
agriculture to manufacturing to the service industry, human capital
grows increasingly important for stimulating local and national economies."
 
The World Bank President, Dr. Jim Yong Kim, defines human capital as
"the sum total of a population's health, skills, knowledge, experience,
and habits." It is a concept that recognizes that not all labor is
equal, and the quality of workers can be improved by investing in them.
 
The US's ranking of 27th in 2016 represents a significant decrease from
its 1990 ranking of 6th. It comes from having 23 years of expected human
capital, measured as the number of years a person can be expected to
work in the years of peak productivity, taking into account life
expectancy, functional health, years of schooling, and learning.
 
Researchers found that nations with greater improvements in human
capital also tend to have faster growth in per capita GDP. Countries in
the highest quartile of improvements in human capital between 1990 and
2016 had a 1.1% higher median yearly GDP growth rate than countries in
the bottom quartile of human capital improvements. For example, between
2015 and 2016, a 1.1% increase in the human capital growth rate in China
equated to an additional $163 per capita; in Turkey, $268 per capita;
and in Brazil, $177 per capita.
 
Read more here:
 
https://www.sciencedaily.com/releases/2018/09/180924190303.htm
 
Second, populism of USA has to be more aware about the advantages of
globalization, so read the following:
 
And about globalization..
 
1- Globalization has created new opportunities for firms to develop
business models and offerings that have a higher intensity of R&D,
innovation and capital. Many of the goods and services that have entered
the market over the past decades have exactly those features, and
without globalization, firms would have been forced to continue with
business models that work with a smaller volume of sales. Firms have
been able to specialize more than before and, as a consequence, human
capital and the share of skilled jobs in the economy have grown
remarkably. Today, advanced economies have a greater share of
better-paid and better-skilled jobs than ever before.
 
2- Globalization has increased real wages for people in Western
economies by making products cheaper or reducing the pace of price
increases. If the typical goods that every household purchases had
followed domestic rather than international price developments,
consumers would have been poorer and saddled with products of lower quality.
 
3- Globalization has made significant contributions to productivity
growth and, as a consequence, further raised living standards.
Globalization has been particularly important for enabling new
technology to spread fast across markets. In the long term, it is the
speed of technological improvement that sets the pace for how richer
societies get.how societies get richer
 
However, trade and investment are not growing fast anymore, and there is
much suggesting that the decline in trade and investment growth is one
explanation to the failing dynamism of Western economies. While some
appreciate the decline in the growth of globalization, those who care
about the prosperity of a society should deplore it and make efforts for
the world economy to return to high levels of trade growth.
 
Read the following study to know more about globalization:
 
The Economic Benefits of Globalization for Business and Consumers
 
http://ecipe.org/publications/the-economic-benefits-of-globalization-for-business-and-consumers/
 
Read the following study to know more about globalization:
 
The Economic Benefits of Globalization for Business and Consumers
 
http://ecipe.org/publications/the-economic-benefits-of-globalization-for-business-and-consumers/
 
 
And read my following thoughts about morality and democracy and God:
 
More about God..
 
You have to be able to do political philosophy to understand God of the
monotheistic religions, God is capable of making it "perfect", and
making it perfect is for example being absolute happiness that is the
goal of morality that is perfection at best, so why God has not created
us of this perfection ? then why are we suffering ? this suffering of
our body and spirit is also "imperfections" that are in contradiction
with the essence of God. So i think we have not to believe in God.
 
 
So now are we lost without God ?
 
I am more mature and i believe that we have to be more optimistic,
because i was looking at morality and i have noticed that it is getting
much more efficient, because we are getting more aware and more
efficient today , thus we have not to make the mistake and get into
hating and hating our world ! because it is easy to hate this or that !
this is why we have to be more mature and be more responsability. and
notice that we are getting much more efficient today with technology and
science ! and we are getting more organized and more sophisticated ! so
you have to be able to love this beautifulness of this much more
efficiency of today ! giving it a high priority and a big importance is
i think the key to success ! so today we have to be more smart and
understand that we also have to work together globally and we have to be
more organized and more order globally ! thus since as i said that
morality is perfection at best , this shows that it is also about
efficiency ! so we have to be more efficient thinking and more efficient
actions ! and you have to understand more correctly what is the at best
of perfection at best that is morality, so read what's follow to be able
to understand:
 
And here is again my previous writing about democracy and morality:
 
I will now do more political philosophy
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.

Thursday, November 29, 2018

Digest for comp.lang.c++@googlegroups.com - 8 updates in 3 topics

woodbrian77@gmail.com: Nov 29 11:39AM -0800

Shalom
 
One of the comments in this thread:
https://www.reddit.com/r/cpp/comments/a14o5q/real_world_problems_with_pragma_once/
 
said that Cray doesn't support pragma once. I know gcc,
Clang and MSVC do support it. I was wondering if Intel,
IBM or Oracle compilers support it.
 
In my software:
https://github.com/Ebenezer-group/onwards
 
I've been using pragma once for a number of years, but
maybe I should switch to using include guards. In the
past I had more include files, but now just have a few,
so switching to include guards would be easy.
Thank you in advance.
 
 
Brian
Ebenezer Enterprises - Enjoying programming again.
http://webEbenezer.net
David Brown <david.brown@hesbynett.no>: Nov 29 09:47PM +0100

> past I had more include files, but now just have a few,
> so switching to include guards would be easy.
> Thank you in advance.
 
I think "#pragma once" is supported by most compilers, but include
guards are supported by /all/ compilers. I would expect performance of
them to be very similar - I know gcc has short-circuit paths in the
pre-processor to make handling of include guards as efficient as possible.
 
Include guards are standard, "#pragma once" is not, but it is so common
that it is unlikely ever to be an issue. I'd not bother changing,
unless someone complains about it not working with their compiler.
 
 
> Brian
> Ebenezer Enterprises - Enjoying programming again.
 
I am glad to hear you are enjoying your programming again. I expect
most of us have been enjoying it since we started. Did you go through a
bad period where programming was an unpleasant chore for you?
Vir Campestris <vir.campestris@invalid.invalid>: Nov 29 09:56PM

On 29/11/2018 20:47, David Brown wrote:
 
> Include guards are standard, "#pragma once" is not, but it is so common
> that it is unlikely ever to be an issue.  I'd not bother changing,
> unless someone complains about it not working with their compiler.
 
To be fast, and standard compliant, I use both.
 
Andy
"Chris M. Thomasson" <invalid_chris_thomasson@invalid.invalid>: Nov 29 12:55PM -0800

On 11/25/2018 10:19 PM, Chris M. Thomasson wrote:
> pointers into a table of locks. A thread can create a little array of
> hashed pointers, sort them, remove duplicates, then take all of the
> locks in the table. The sorting and uniqueness factor prevents deadlock.
[...]
> Will post more info sometime tomorrow.
 
This allows one to lock addresses without having to create a mutex for
each one. Just pass the address of a variable to a thread local lock
set, lock it, and the variable is now locked wrt mutual exclusion.
 
Now, to make this more fine grain, what about a multex that used
read-write locks? A thread can have two classes of lock sets, reads and
writes.
wyniijj@gmail.com: Nov 28 04:26PM -0800

Öö Tiib於 2018年11月28日星期三 UTC+8下午9時13分36秒寫道:
 
> > It works, but hardly to say better than pre-C++11 style,
> > after having read https://en.cppreference.com/w/cpp/language/constant_expression
 
> I do not understand what is your point and what is "better".
 
I was trying to use constexpr and to know that the code has to be
written like pre-c++11 style (a bit frustrated, c++17 way is 'better')
 
> Yes, to learn C++ one has to read quite a lot of manuals and
> books.
 
That sayed a lot.
Is it good or bad one has to read A LOT c++ manuals and books?
 
> > usage experiences.
 
> So ... C++11 added sub-bar constexpr and therefore C++11 is enough
> for you?
 
I can read just common, less cultural English, can't figure out 'sub-bar'.
And yes, c++11 should be enough for me, I hope.
 
> Python is scripting language that entirely ignores those
> concerns. Where efficiency is needed there it calls
> C or C++ programs or modules.
 
If some new keyword(or ...) is invented to improve convenience and
optimiztion, I am sure it wil do, but also sure other 'untouched'
part will suffer the opposite effect to the extent proportional to
that the new thing convers, not yet mentioning the complexity and
user/developer burdon grows by multipication when they are mixed in
use/consideration.
I rember Bjarne Stroustrup used to be very careful abour the core
part of the language. But stuffs after c++11 are more and more
'for fun' looked to me (much less insightful).
 
I am seeing programming languages from the perspective of the user,
not developer. So whatever the underlying language should not be
relevant to the user language in this concern. I don't like Python
but it is favored more than c++ by many is fact.
"Öö Tiib" <ootiib@hot.ee>: Nov 29 05:24AM -0800

> > books.
 
> That sayed a lot.
> Is it good or bad one has to read A LOT c++ manuals and books?
 
It is difficulty. Lot of somewhat overlapping features, more
variance in ways to reach same result. Often the differences
in fitness for particular purpose are small and so the
differences of readability, safety, reliability and/or performance
of result will be also small. It is complicated to learn to realize
when these differences might be significant. Hard to master,
hard to beat when mastered.
 
> > for you?
 
> I can read just common, less cultural English, can't figure out 'sub-bar'.
> And yes, c++11 should be enough for me, I hope.
 
My English is anyway bad. I meant that features added by C++11
were really major but somewhat inconveniently or weakly thought
thru. C++14 and C++17 have attempted to fix it, not to add much
new.
 
> I rember Bjarne Stroustrup used to be very careful abour the core
> part of the language. But stuffs after c++11 are more and more
> 'for fun' looked to me (much less insightful).
 
The constexpr function of C++11 can contain only one, return,
statement. That is clearly too limiting.
 
> not developer. So whatever the underlying language should not be
> relevant to the user language in this concern. I don't like Python
> but it is favored more than c++ by many is fact.
 
User Is using software. User does not care with what tools it
is made. Programming language is tool of developer.
So it is developer who should choose what tool to use
for what task. Python is better tool for some situations,
C++ for other situations.
jameskuyper@alumni.caltech.edu: Nov 29 05:44AM -0800

On Thursday, November 29, 2018 at 8:25:08 AM UTC-5, Öö Tiib wrote:
> On Thursday, 29 November 2018 02:26:25 UTC+2, wyn...@gmail.com wrote:
> > Öö Tiib於 2018年11月28日星期三 UTC+8下午9時13分36秒寫道:
...
> were really major but somewhat inconveniently or weakly thought
> thru. C++14 and C++17 have attempted to fix it, not to add much
> new.
 
I suspect you meant "sub-par" <https://en.wiktionary.org/wiki/sub-par>.
scott@slp53.sl.home (Scott Lurndal): Nov 29 01:47PM

>>=20
 
>I can read just common, less cultural English, can't figure out 'sub-bar'.
>And yes, c++11 should be enough for me, I hope.
 
The expression 'sub-par' generally means at a quality less than
average. Yet in the game of golf, sub-par is actually excellent :-)
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 - 1 update in 1 topic

deepthibargav@gmail.com: Nov 28 09:16PM -0800

Hi All,
 
 
It would be of great help if someone could tell me how to find if two threads are trying to operate on a same mutex?
 
I also want to find the entire communication that happens with respect to locks while the program is being run,
 
I came to know about this forum from some researcher. any inputs will be of immense help.
 
 
Regards,
Deepthi
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.

Wednesday, November 28, 2018

Digest for comp.lang.c++@googlegroups.com - 18 updates in 3 topics

Ralf Goertz <me@myprovider.invalid>: Nov 28 11:44AM +0100

Hi,
 
is there a reason why there is no function "std::binary_find" which has
an interface like "std::find" but takes advantage of the fact that the
input is sorted? At least I have found no such function. Of course
std::set.find could be an option but I guess its performance is much
worse than that of a binary_find in a sorted vector.
leigh.v.johnston@googlemail.com: Nov 28 03:04AM -0800

On Wednesday, November 28, 2018 at 10:44:58 AM UTC, Ralf Goertz wrote:
> input is sorted? At least I have found no such function. Of course
> std::set.find could be an option but I guess its performance is much
> worse than that of a binary_find in a sorted vector.
 
std::lower_bound
 
/Leigh
Ralf Goertz <me@myprovider.invalid>: Nov 28 12:22PM +0100

Am Wed, 28 Nov 2018 03:04:48 -0800 (PST)
> > performance is much worse than that of a binary_find in a sorted
> > vector.
 
> std::lower_bound
 
"Returns an iterator pointing to the first element in the range [first,
last) that is not less than (i.e. greater or equal to) value, or last if
no such element is found."
 
So I still need to check that the element pointed to is actually the one
I was looking for. Given the redundancy in <algorithm> (e.g.
std::find_if and std::find_if_not) the existence of st::lower_bound is
not a good enough reason not to have std::binary_find.
leigh.v.johnston@googlemail.com: Nov 28 03:42AM -0800

On Wednesday, November 28, 2018 at 10:44:58 AM UTC, Ralf Goertz wrote:
> input is sorted? At least I have found no such function. Of course
> std::set.find could be an option but I guess its performance is much
> worse than that of a binary_find in a sorted vector.
 
std::lower_bound and std::upper_bound are perfectly adequate for doing the job of your "binary_find" which is not needed.
 
/Leigh
leigh.v.johnston@googlemail.com: Nov 28 04:29AM -0800

On Wednesday, November 28, 2018 at 10:44:58 AM UTC, Ralf Goertz wrote:
> input is sorted? At least I have found no such function. Of course
> std::set.find could be an option but I guess its performance is much
> worse than that of a binary_find in a sorted vector.
 
There is also std::equal_range
 
/Leigh
James Kuyper <jameskuyper@alumni.caltech.edu>: Nov 28 07:41AM -0500

On 11/28/18 05:44, Ralf Goertz wrote:
 
> is there a reason why there is no function "std::binary_find" which has
> an interface like "std::find" but takes advantage of the fact that the
> input is sorted? At least I have found no such function.
 
Just to confirm: you're looking for a standard function with behavior
equivalent to:
 
 
template<class ForwardIterator, class T>
ForwardIterator binary_find(
ForwardIterator first,
ForwardIterator last, const T& value)
{
ForwardIterator iter =
lower_bound(first, last, value);
if(*iter == value)
return iter;
return last;
}
 
 
> ... Of course
> std::set.find could be an option but I guess its performance is much
> worse than that of a binary_find in a sorted vector.
 
Both should be logarithmic, but I could imagine that std::set::find()
might be slower - but that only matters if you're free to choose your
data structure based solely upon this one operation. Whether you use
std::set or a sorted vector should also depend on how you'll be
initializing and modifying the contents of your container, and that's
often the determining issue, unless you will be searching the container
far more often than you modify its contents.
James Kuyper <jameskuyper@alumni.caltech.edu>: Nov 28 07:44AM -0500

On 11/28/18 05:44, Ralf Goertz wrote:
 
> is there a reason why there is no function "std::binary_find" which has
> an interface like "std::find" but takes advantage of the fact that the
> input is sorted? At least I have found no such function.
 
Just to confirm: you're looking for a standard function with behavior
equivalent to:
 
 
template<class ForwardIterator, class T>
ForwardIterator binary_find(
ForwardIterator first,
ForwardIterator last, const T& value)
{
ForwardIterator iter =
lower_bound(first, last, value);
if(iter !=last && *iter == value)
return iter;
return last;
}
 
 
> ... Of course
> std::set.find could be an option but I guess its performance is much
> worse than that of a binary_find in a sorted vector.
 
Both should be logarithmic, but I could imagine that std::set::find()
might be slower - but that only matters if you're free to choose your
data structure based solely upon this one operation. Whether you use
std::set or a sorted vector should also depend on how you'll be
initializing and modifying the contents of your container, and that's
often the determining issue, unless you will be searching the container
far more often than you modify its contents.
Juha Nieminen <nospam@thanks.invalid>: Nov 28 01:58PM

> I was looking for. Given the redundancy in <algorithm> (e.g.
> std::find_if and std::find_if_not) the existence of st::lower_bound is
> not a good enough reason not to have std::binary_find.
 
In principle the main idea behind std::lower_bound and std::upper_bound
is that you can insert the searched element at the place pointed by
the iterator they return, and the container will remain sorted.
(Their difference is that with std::lower_bound the new element will
be inserted before any possibly existing element that's equal to the
searched one, while with std::upper_bound it will be inserted after any
such element.) They don't really take a stance on whether an equal element
already exists in the container.
 
With std::lower_bound you can check the element pointed by the returned
iterator to see if it's equal to the searched one.
Ralf Goertz <me@myprovider.invalid>: Nov 28 03:10PM +0100

Am Wed, 28 Nov 2018 07:44:05 -0500
> return iter;
> return last;
> }
 
Yes, and that is exactly how I implemented it (after looking at
std::binary_search). And I am curious as to why I had to do that. The
fact that it is not so difficult to implement can hardly be the reason
not to provide it. std::binary_search is almost as easy as that but it
is provided by the standard. I guess the need for finding the actual
position of the element is not unreasonable, it is one of the reasons I
don't want to use std::set because std::distance(first, iter) is also
not that trivial.
 
> initializing and modifying the contents of your container, and that's
> often the determining issue, unless you will be searching the
> container far more often than you modify its contents.
 
Exactly. I love std::set but in my use case it is not appropriate.
"Öö Tiib" <ootiib@hot.ee>: Nov 28 08:00AM -0800

On Wednesday, 28 November 2018 12:44:58 UTC+2, Ralf Goertz wrote:
 
> is there a reason why there is no function "std::binary_find" which has
> an interface like "std::find" but takes advantage of the fact that the
> input is sorted? At least I have found no such function.
 
It sounds too close to std::lower_bound or std::equal range
to matter.
Positive side of std::lower_bound is that it gives the place
where to insert when an element was not found. That is
actually quite common need.
 
> Of course
> std::set.find could be an option but I guess its performance is much
> worse than that of a binary_find in a sorted vector.
 
That can't be sure until measured. Also the std::unordered_set::find
can be even better. Performance of concrete use-case is still
somewhat predictable but typically every container participates
in several use-cases and what is best for one use-case can be
worst for other.
"Alf P. Steinbach" <alf.p.steinbach+usenet@gmail.com>: Nov 28 05:34PM +0100

On 28.11.2018 11:44, Ralf Goertz wrote:
> input is sorted? At least I have found no such function. Of course
> std::set.find could be an option but I guess its performance is much
> worse than that of a binary_find in a sorted vector.
 
Don't know, but I regard as a design level defect that
¹`std::binary_search` discards the information about where it found the
specified value, and only returns a `bool`. Nonsensical design IMHO. :(
 
Cheers!,
 
- Alf
 
Notes:
¹ `https://en.cppreference.com/w/cpp/algorithm/binary_search
Juha Nieminen <nospam@thanks.invalid>: Nov 28 07:28PM

> Positive side of std::lower_bound is that it gives the place
> where to insert when an element was not found. That is
> actually quite common need.
 
Nothing stops you from inserting the element at the returned
position even if an equal element already exists. The container
will still be sorter afterwards.
wyniijj@gmail.com: Nov 27 04:09PM -0800

Öö Tiib於 2018年11月28日星期三 UTC+8上午12時28分20秒寫道:
> your file ...:
 
> constexpr Str Token::Pi;
 
> ... will make it to compilöe with -std=c++11 too.
 
It works, but hardly to say better than pre-C++11 style,
after having read https://en.cppreference.com/w/cpp/language/constant_expression
 
 
> The constexpr of C++17 on the other hand feels like a way to
> mark pure functions (in functional programming sense) with keyword
> constexpr.
 
c++11 solved many previous deficiencies but also introduced many fold
complexity of the language for really nothing worthy of, relatively.
So c++11 should be enough for me, I have no time to resolve those
newly invented use-cases and corner issues. Thanks anyway, for your
usage experiences.
 
> Preferring pureness is quite good programming idiom
> in general, about like preferring immutability is good programming
> idiom in general.
 
Let's say. my philosophy is reality. I feel Python is becoming much
more popular and requested from the job market, than c++.
(pureness? immutability?)
"Öö Tiib" <ootiib@hot.ee>: Nov 28 05:13AM -0800


> > ... will make it to compilöe with -std=c++11 too.
 
> It works, but hardly to say better than pre-C++11 style,
> after having read https://en.cppreference.com/w/cpp/language/constant_expression
 
I do not understand what is your point and what is "better".
Yes, to learn C++ one has to read quite a lot of manuals and
books.
 
> So c++11 should be enough for me, I have no time to resolve those
> newly invented use-cases and corner issues. Thanks anyway, for your
> usage experiences.
 
So ... C++11 added sub-bar constexpr and therefore C++11 is enough
for you?
 
 
> Let's say. my philosophy is reality. I feel Python is becoming much
> more popular and requested from the job market, than c++.
> (pureness? immutability?)
 
You compare different tools and philosophies.
Pureness and immutability help both people and compilers to
reason about code and to improve or to optimize it.
Python is scripting language that entirely ignores those
concerns. Where efficiency is needed there it calls
C or C++ programs or modules.
Jorgen Grahn <grahn+nntp@snipabacken.se>: Nov 28 06:47AM

On Mon, 2018-11-26, Paavo Helde wrote:
> std) encouraging a safe way to use these features correctly.
 
> I am meaning things like the condition_variable wait taking a reference
> to the lock, as well as the predicate to wait for. This is a huge step
[etc]
 
That's true, and it's a good thing. Hopefully people now write
clearer and more correct threaded code than in the past -- because of
the facilities available, and because threading is better understood.
 
BTW, I see little mention of the higher-level concurrency mechanisms
in C++11 here. Do people use std::future, std::promise and so on?
 
/Jorgen
 
--
// Jorgen Grahn <grahn@ Oo o. . .
\X/ snipabacken.se> O o .
"Chris M. Thomasson" <invalid_chris_thomasson@invalid.invalid>: Nov 27 11:08PM -0800

On 11/27/2018 10:47 PM, Jorgen Grahn wrote:
> the facilities available, and because threading is better understood.
 
> BTW, I see little mention of the higher-level concurrency mechanisms
> in C++11 here. Do people use std::future, std::promise and so on?
 
Yes: Here is an older discussion, before this was even standard:
 
https://groups.google.com/forum/#!original/comp.lang.c++/nKgbzzJ5nXU/Aqgcj1NOIHEJ
 
Here is the response I got from Scott:
 
https://groups.google.com/forum/#!original/comp.lang.c++/nKgbzzJ5nXU/ECyORKsMwygJ
"Chris M. Thomasson" <invalid_chris_thomasson@invalid.invalid>: Nov 28 12:48AM -0800

On 11/26/2018 12:50 PM, David Brown wrote:
> interactions (used appropriately, of course), and where
> implementation-specific code and features are fine.  And the OS'es in my
> world are often written in C90 - not even C99.
 
Fwiw, here is an old school x86 impl of a fast pathed read-write mutex I
invented a while back, before anything was standard, notice volatile? It
does use inline asm, but ahh shi% let it ride! ;^)
 
https://pastebin.com/raw/f3d6140eb
 
It should work with GCC and MSVC... Heck it even uses POSIX semaphores,
the right way. Every been bitten by failing to loop back around and wait
again on a sem_wait that returns EINTR?
 
Notice the following function:
_____________________
static void
sem_wait_safe(
sem_t* const self
) {
while (sem_wait(self)) {
if (errno != EINTR) abort();
}
}
_____________________
 
I just blast errors into abort in this old code.
Chris Vine <chris@cvine--nospam--.freeserve.co.uk>: Nov 28 12:19PM

On 28 Nov 2018 06:47:09 GMT
Jorgen Grahn <grahn+nntp@snipabacken.se> wrote:
[snip]
> BTW, I see little mention of the higher-level concurrency mechanisms
> in C++11 here. Do people use std::future, std::promise and so on?
 
I don't think std::future is super useful in many cases. It's purpose
is to synchronize by having one thread (the consumer) wait for another
(the producer) to complete where the promise has not been fulfilled. So
it doesn't really implement effective parallelism unless in the use
case in question the consumer rarely waits, or unless every relevant
computation runs in its own thread and you let the thread scheduler
deal with the situation (which can result in thread limits, as well as
performance, being hit).
 
Constructing a chain of continuations with std::future::then() is
sometimes put forward as a solution to unnecessary waiting. It isn't
really, because it is sequential and at the end of the chain of
continuations there is still a future which has to be waited on:
furthermore each std::future::then() continuation spawns a new thread
rather than reusing the old completed one - if that is what you want,
better is to wrap your chain of function calls in a single lambda
expression and execute that via std::async or whatever, so at least
they all execute in the same thread.
 
Most programs I have an interest in use an event loop, because they
have a GUI or employ asynchronous i/o. In the absence of work
stealing, that often solves the problem quite nicely - instead of
waiting on a std::future object, at the end of the computation (which
may be running on a standard thread pool) you can post the continuation
of the computation to the event loop to be dealt with in the main
thread asynchronously. This has been popularised by OS X's Grand
Central Dispatch. I suppose the problem from the standard C++ point of
view is that such event loops are GUI/implementation dependent and so
cannot readily be standardised. Furthermore it is difficult to compose
parallel tasks this way, unless the problem can be turned into
something like a functional map-reduce over a container (in C++, say a
parallel_transform() followed by a parallel_accumulate(), running on a
thread pool), and posting the continuation of that to the event loop.
 
Work stealing fork/join seems to be another popular solution, by
generalising that kind of composition.
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.