Tuesday, December 27, 2016

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

Paavo Helde <myfirstname@osa.pri.ee>: Dec 27 08:03PM +0200

On 24.12.2016 5:00, Alf P. Steinbach wrote:
> struct Dynamic_only
> {
> void selfdestroy() { delete this; }
 
I have had similar desires in the past to demand only dynamic allocation
for some classes and I went to great lengths to develop my own
smartpointers which supported that. However, by now I have come to
conclusion that these desires were futile and actually not needed for
anything.
 
First note that internal refcounting cannot be made work with
std::shared_ptr in principle, as std::shared_ptr also supports
thread-safe weak pointers, but such weak pointers are not compatible
with internal reference counters (a race condition between weak pointer
mechanisms and the object destructor).
 
So, if one wants to use std::shared_ptr, one cannot use internal
reference counting. This actually solves one of the reasons why one
might want to prohibit stack allocation - if there is no selfdestroy()
function then there is no danger that somebody might accidentally call
it and try to delete an object which has not been allocated dynamically.
 
There remains the danger in that a std::shared_ptr can be constructed
from an unusable raw pointer like 'this' or &x (this practice would work
fine in a legacy codebase using some kind of intrusive refcounting, but
not with std::shared_ptr).
 
For performance reasons we wanted to use std::make_shared() or
std::allocate_shared() anyway instead of plain new, so there was no
point in allowing to construct a std::shared_ptr() from a raw pointer.
Alas, this constructor is there and will not go away. So, in our
codebase, to mitigate this problem, I created another wrapper pointer
class derived from std::shared_ptr which has the constructor from raw
pointer deleted. All the code uses this class rather than
std::shared_ptr, which basically eliminates the possibility of accidents.
 
As the end result, one can now create local stack objects of those types
and these work fine, one just cannot obtain a valid smartpointer to such
an object (and creating an invalid smartpointer requires some conscious
mischief).
David Brown <david.brown@hesbynett.no>: Dec 27 10:39AM +0100

On 23/12/16 21:08, Daniel wrote:
 
>> "God made the integers, all else is the work of man"
 
> Depends where you want to start. You can start with set theory, and derive the
> integers as equivalence classes. Mr Fliblle, as you note, starts with sausages.
 
Yes, you have to start somewhere. If you pick axiomatic set theory, you
can derive integers from there - but you can keep going and make
rationals, reals, complex numbers, infinite cardinals and ordinals (who
volunteers to explain to Mr. Flibble that the first countably infinite
ordinal, ω, has 1 + ω = ω, but ω + 1 > ω ?), and any other mathematics
you like. From a mathematical viewpoint, integers are as constructed as
anything else.
 
I don't think anyone has thought of a system more fundamental than set
theory (from which set theory could be derived). But maybe someone will
eventually.
 
Mr Flibble <flibble@i42.co.uk>: Dec 27 05:48PM

On 27/12/2016 09:39, David Brown wrote:
> 1 + ω = ω
 
If "+" means addition than 1 + ω = ω is patently false.
 
/Flibble
Mr Flibble <flibble@i42.co.uk>: Dec 27 05:53PM

On 27/12/2016 17:48, Mr Flibble wrote:
> On 27/12/2016 09:39, David Brown wrote:
>> 1 + ω = ω
 
> If "+" means addition than 1 + ω = ω is patently false.
 
This of course is predicated on ω being a variable and not a
classification: if it is a classification then I assume it means
something along the lines of:
 
1 + an integer = an integer
 
So basically, David Brown, stop being such a pompous dick.
 
/Flibble
Ian Collins <ian-news@hotmail.com>: Dec 27 12:34PM +1300

On 12/27/16 10:54 AM, Jeff-Relf.Me wrote:
 
> Local definitions override previous ones.
 
> Underscores are too useful to not use.
 
> "Standards" are like assholes, everyone's got one.
 
Only Americans...
 
--
Ian
Paavo Helde <myfirstname@osa.pri.ee>: Dec 27 01:17AM +0200

On 26.12.2016 23:51, Jeff-Relf.Me wrote:
>> such identifiers.
 
> Macros are _good_, you should use them.
> Who wouldn't prefer Loop(4) over "for( i=0; I <= 3; i++ )" ?
 
I started to write down a 10-bullet answer for that question, but then I
realized that you must be just trolling as nobody can't be that stupid.
 
> You must be prejudiced; afraid of change.
 
I have changed away from C and macro madness and have no plans to go
back, thank you.
Jeff-Relf.Me <@.>: Dec 26 05:31PM -0800

woodbrian77@gmail.com: Dec 26 05:41PM -0800

On Saturday, December 24, 2016 at 3:40:50 AM UTC-6, Peter Köhlmann wrote:
 
Please don't swear here.
 
 
Brian
Ebenezer Enterprises
http://webEbenezer.net
Jeff-Relf.Me <@.>: Dec 26 05:45PM -0800

Ian Collins <ian-news@hotmail.com>: Dec 27 03:28PM +1300

> On Saturday, December 24, 2016 at 3:40:50 AM UTC-6, Peter Köhlmann wrote:
 
> Please don't swear here.
 
He didn't.
 
--
Ian
jonkalb <google@kalbweb.com>: Dec 26 11:24PM -0800

On Friday, December 23, 2016 at 5:06:58 PM UTC-8, Jeff-Relf.Me wrote:
> My C++ Coding Standards ( apologies to Bjarne Stroustrup ):
 
I think you need to apologize to more than Bjarne. You should apologize to WG21 and to the entire C++ coding community.
 
When I first saw your coding guidelines I honestly thought you had your tongue in your cheek and were writing one of those lists where instead of giving good advice you deliberately give bad advice to dramatize common mistakes and show people what to avoid.
 
It is only after reading your responses to the comments here that I realized that you were sincere in your recommendations.
 
Jeff, I'm really happy that writing code this way has put food on your table since 1981. My guess is that, since you happen to be exactly my age, it is too late for you to learn "new tricks" so you'll almost certainly just run out the clock on your career writing code like this.
 
But I beg of you, two things. One is that you never ask me to review or any way work with any code you've ever written and the second is that you never share your coding standards or other coding advise with anyone else in the C++ community. Ever.
 
Thanks ever so much.
 
Jon
Paavo Helde <myfirstname@osa.pri.ee>: Dec 27 10:01AM +0200

On 27.12.2016 3:45, Jeff-Relf.Me wrote:
 
>> I have changed away from C and macro madness
>> and have no plans to go back, thank you.
 
> From C to what, PHP ?
 
If you haven't figured out in 40 years that C and C++ are different
languages, then I guess it's too late for you now.
 
> My professional C++ code gets input from, and outputs to Excel 2016.
 
What C++ code? What you have posted online so far is bad C, with fixed
size arrays and unsafe sprintf() variants.
 
 
> PHP could use #define, seriously.
 
PHP is not written in C++.
Paavo Helde <myfirstname@osa.pri.ee>: Dec 27 01:25PM +0200

On 27.12.2016 3:31, Jeff-Relf.Me wrote:
 
> _Underscores have never been -- and could never be -- a problem.
> If I had to rename some variables/funcs/macros, I would,
> _No _Big _Deal; meanwhile, they're _Useful.
 
Of course they are no problem for you. They are a problem for another
guy or gal who includes your headers in good faith, together with some
standard includes, and then cannot understand why the code fails
compiling deep inside the standard headers. There would be no indication
that the actual problem is in your header.
 
Been there, done that (long time ago). It took me half a day to figure
out why the code stopped compiling after adding an innocent #include
<string> line, with mysterious error messages from deep inside system
headers. It came out that somebody had defined a macro named _B in some
header included by a header included by a header.
"Öö Tiib" <ootiib@hot.ee>: Dec 27 05:58AM -0800

On Tuesday, 27 December 2016 03:31:17 UTC+2, Jeff-Relf.Me wrote:
 
> I use Visaul Studio 2015, exclusively;
> so my code conforms to its standards,
> C++11, C++14 and C++17 ( anticipated ).
 
Playing daff? I keep telling you that _Loop is reserved name
that programmers should not use by every of these
standards.
 
 
> _Underscores have never been -- and could never be -- a problem.
> If I had to rename some variables/funcs/macros, I would,
> _No _Big _Deal; meanwhile, they're _Useful.
 
All code (so also every construct with defects in it) can be easily
edited and modified. That does not make written undefined
behavior or other bugs not a problem. In my experience about 80%
effort goes into fixing bugs anyway so making more deliberately
is irrational, unless that is meant as sabotage. Especially when that
underscore there gives no benefits whatsoever.
 
 
> Are you _Really worried about compilers "ripping you a new one" ? !
> How old are you ? I started coding in _1976, when I was _16.
> Ever since _1981, it has paid my rent.
 
Can't you read? I wrote that those likely won't manifest. Only
sometimes waste time pointlessly. Why to make such defects
knowingly?
Jeff-Relf.Me <@.>: Dec 27 09:10AM -0800

ram@zedat.fu-berlin.de (Stefan Ram): Dec 27 03:08PM

>For a restriction to dynamic allocation by making the destructor
>non-`public`, I wonder what would be a good way to support destructor
>invocation via `std::shared_ptr` and other smart pointers?
 
Another idea was to have a private destructor and then friend
the shared pointer class.
 
class dynamic_only { friend ::std::shared_ptr< dynamic_only >; ~~~ }
 
But this did not work. There might be two reasons for the failure:
First, there are additional implementation-specific helper classes
involved that would also have to be friended. Second, there might
be explicit tests in the implementation to make sure that the
destructor is public.
Cholo Lennon <chololennon@hotmail.com>: Dec 27 11:33AM -0300

On 12/11/2016 02:16 AM, kushal bhattacharya wrote:
> to put it in a correct way this config file will have xml and json
 
Take a look at Boost Property Tree library (it supports different
formats: ini, json, xml, etc)
 
 
--
Cholo Lennon
Bs.As.
ARG
David Brown <david.brown@hesbynett.no>: Dec 27 10:47AM +0100

On 26/12/16 02:04, Rick C. Hodgin wrote:
 
> FWIW, as I was reading it, I honestly thought you were trying to do
> the exact opposite of what was right in many areas. But, I checked
> the calendar and it's not April 1 ... so I'm at a loss.
 
People make jokes at other times of the year...
chrisv <chrisv@nospam.invalid>: Dec 27 07:11AM -0600

Mr Flibble wrote:
 
>On 25/12/2016 21:39, Jeff-Relf.Me wrote:
 
*plonk*
Mr Flibble <flibbleREMOVETHISBIT@i42.co.uk>: Dec 26 07:58PM -0600

> the death of Jesus Christ as being absolutely meaningless.
 
> To accept evolution is to deny God with a full force rebellion
> against Him. You might as well be spitting in His face.
 
If he was real I would spit in his face because he is evil but he isn't
real; evolution is real.
 
/Flibble
"Rick C. Hodgin" <rick.c.hodgin@gmail.com>: Dec 26 06:49PM -0800

Mr Flibble wrote:
> If he was real I would spit in his face because he is evil but he isn't
> real; evolution is real.
 
You're very intelligent, Leigh. Gifted. Accomplished. But there are
some things you don't have a proper handle on yet. If you're interested,
there is a path to the truth. You can even discover it on your own just
by seeking it. But there are others who will also help guide you if you
want.
 
You have tremendous value, Leigh. It's why He offers salvation for free.
He counts everything He went through to pay the price of sin as so very
precious and dear. His love for His creation to save them from sin, and
deliver them from death. It's a steep price He paid, byt because if His
love ... He doesn't pass that price on to us. All can come to Him and be
saved ... even those who, like me, once said He wasn't real.
 
-----
Love. Jesus is love, Leigh. When you look to that cross, and you look
at the sin in your life, and realize what God dud for us while we were
yet sinners ... it'll open up the fountains of your eyes. At least
that's been my experience.
 
Best regards,
Rick C. Hodgin
Ian Collins <ian-news@hotmail.com>: Dec 27 09:19PM +1300

On 12/27/16 03:49 PM, Rick C. Hodgin wrote:
>> If he was real I would spit in his face because he is evil but he isn't
>> real; evolution is real.
 
> You're very intelligent, Leigh.
 
Which is why he doesn't fall for the off-topic fairy tales and
pseudo-science you keep peddling on these groups.
 
--
Ian
"Rick C. Hodgin" <rick.c.hodgin@gmail.com>: Dec 27 03:16AM -0800

Ian Collins wrote:
> > You're very intelligent, Leigh.
 
> Which is why he doesn't fall for the off-topic fairy tales and
> pseudo-science you keep peddling on these groups.
 
I do not describe fairy tales, but truth. And I ask you to personally
investigate and prove out for yourself every one of my claims. Every
one. You'll find every one holds up to the most intense scrutiny, and
every aspect of observable science because it is the truth.
 
Truth has a name, Ian: Jesus.
 
John 14:6.
 
Best regards,
Rick C. Hodgin
Melzzzzz <Melzzzzz@zzzzz.com>: Dec 27 11:30AM

> one. You'll find every one holds up to the most intense scrutiny, and
> every aspect of observable science because it is the truth.
 
> Truth has a name, Ian: Jesus.
 
I don't usually swear, but fuck the truth. God is dead. Satan lives!
 
 
--
press any key to continue or any other to quit...
woodbrian77@gmail.com: Dec 26 10:00PM -0800

On Friday, November 25, 2016 at 12:12:51 PM UTC-6, David Brown wrote:
> of superstition. You are also free to make your own choices about your
> sexuality (to the extent that it is under your concious control). You
> are /not/ free to impose them on other people, in any way.
 
 
http://www.dailywire.com/news/11861/wake-trump-democrats-suddenly-discover-freedom-ben-shapiro
 
"Suddenly, it seems, the left has discovered freedom of association.
After years of telling religious people that they had a moral
and legal obligation to throw out their religion and serve same-sex
weddings, provide contraception, and fund abortion, the left now
realizes that the ability to pick and choose those to whom you give
your services is actually rather vital.
 
Don't expect it to last.
 
Of course artists should be able to turn down clients. So should
religious bakers. But you won't see the left acknowledge that.
The only freedom to turn down clients is the freedom for leftists
to turn down conservative and religious clients, not the other
way around."
 
Ben would be happy to know that I have the freedom to turn
down clients also. Freedom isn't free and this freedom of
mine has come at a price.
 
 
Brian
Ebenezer Enterprises - In G-d we trust.
http://webEbenezer.net
You received this digest because you're subscribed to updates for this group. You can change your settings on the group membership page.
To unsubscribe from this group and stop receiving emails from it send an email to comp.lang.c+++unsubscribe@googlegroups.com.

No comments: