Tuesday, January 10, 2023

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

Juha Nieminen <nospam@thanks.invalid>: Jan 10 05:56AM

> When you make unsupported and unjustified claims that all of /your/
> opinions are somehow "uncontroversial fact", then it is entirely
> appropriate to say you are being arrogant.
 
There we go again reading between the lines and putting in my mouth words
I have never said.
 
> one of the authorities you have appealed to as though it were proof of
> your case. In particular, read :
 
> <https://google.github.io/styleguide/cppguide.html#General_Naming_Rules>
 
The irony. That's exactly one of the things I quoted earlier in this
thread that what I am saying is quite widely accepted and used in
coding guidelines out there. It's not something I came up with.
 
"Use names that describe the purpose or intent of the object. Do not
worry about saving horizontal space as it is far more important to make
your code immediately understandable by a new reader. Minimize the use
of abbreviations that would likely be unknown to someone outside your
project (especially acronyms and initialisms). Do not abbreviate by
deleting letters within a word. As a rule of thumb, an abbreviation
is probably OK if it's listed in Wikipedia."
 
> And if this post does not convince you, it is probably because it is too
> long and too verbose - making it hard to read and understand.
 
You can go fuck yourself as well.
"Öö Tiib" <ootiib@hot.ee>: Jan 09 10:48PM -0800

On Tuesday, 10 January 2023 at 07:57:14 UTC+2, Juha Nieminen wrote:
> project (especially acronyms and initialisms). Do not abbreviate by
> deleting letters within a word. As a rule of thumb, an abbreviation
> is probably OK if it's listed in Wikipedia."
 
You really stopped reading there? It even brings example similar to what
you argued is good naming. BAD:
for (int foo_index = 0; foo_index < foos.size(); ++foo_index) { // Use idiomatic `i`
 
> > And if this post does not convince you, it is probably because it is too
> > long and too verbose - making it hard to read and understand.
 
> You can go fuck yourself as well.
 
That is what you consider like not arrogant?
David Brown <david.brown@hesbynett.no>: Jan 10 09:11AM +0100

On 10/01/2023 06:56, Juha Nieminen wrote:
>> appropriate to say you are being arrogant.
 
> There we go again reading between the lines and putting in my mouth words
> I have never said.
 
Are you now trying to tell us that you haven't claimed your position is
"uncontroversial" ? Seriously?
 
 
> The irony. That's exactly one of the things I quoted earlier in this
> thread that what I am saying is quite widely accepted and used in
> coding guidelines out there. It's not something I came up with.
 
It is not ironic - why do you think I picked the Google style guide? I
read your posts. I don't believe you have made effort to read anyone
else's, or to try to understand them, but I certainly read yours. I
picked this style guide because /you/ have tried to use it as an "appeal
to authority" support, but apparently have not read it yourself (I have)
since it does not support your argument. It supports the opinion of
those that disagree with you.
 
> project (especially acronyms and initialisms). Do not abbreviate by
> deleting letters within a word. As a rule of thumb, an abbreviation
> is probably OK if it's listed in Wikipedia."
 
Amazing. You can quote /most/ of a paragraph, and yet still manage to
miss the critical next couple of sentences:
 
"""
Generally speaking, descriptiveness should be proportional to the name's
scope of visibility. For example, n may be a fine name within a 5-line
function, but within the scope of a class, it's likely too vague.
"""
 
And then in the good example given:
 
 
int n = 0; // Clear meaning given limited scope and context
for (const auto& foo : foos) {
 
 
and the bad example:
 
 
int total_number_of_foo_errors = 0; // Overly verbose given
limited scope and context
for (int foo_index = 0; foo_index < foos.size(); ++foo_index) { //
Use idiomatic `i`
 
 
 
So Google's style guide agrees on the part everyone agrees on (though
you still haven't acknowledged that you understand this). And on the
issue where the majority of people in this thread disagree with you, it
sides with us and against your argument.
 
I don't see Google as being authoritative here (or anywhere else) - but
their opinions and preferences coincide with those of other guides I
have seen, and most other people who have discussed it. /You/ are the
exception - the only person I know who feels that "foo_index" is a
better choice for a loop index than "i", even in a short loop. You are
welcome to have that opinion - all I ask is that you understand that it
is /only/ an opinion, and that it differs from other opinions.
 
 
 
>> And if this post does not convince you, it is probably because it is too
>> long and too verbose - making it hard to read and understand.
 
<snip>
 
 
Just go and read the Google style guide section "General Naming Rules".
Read /all/ of it this time.
Juha Nieminen <nospam@thanks.invalid>: Jan 10 11:08AM

>> > long and too verbose - making it hard to read and understand.
 
>> You can go fuck yourself as well.
 
> That is what you consider like not arrogant?
 
Responding to mockery with expletives is not arrogance but frustration
and anger.
"Öö Tiib" <ootiib@hot.ee>: Jan 10 03:28AM -0800

On Tuesday, 10 January 2023 at 13:09:08 UTC+2, Juha Nieminen wrote:
 
> > That is what you consider like not arrogant?
 
> Responding to mockery with expletives is not arrogance but frustration
> and anger.
 
Why you are angry? I thought David was kind of self-ironic. His post
(about how shorter text is sometimes easier to understand) can be
considered overly verbose indeed.
David Brown <david.brown@hesbynett.no>: Jan 10 04:26PM +0100

On 10/01/2023 12:28, Öö Tiib wrote:
 
> Why you are angry? I thought David was kind of self-ironic. His post
> (about how shorter text is sometimes easier to understand) can be
> considered overly verbose indeed.
 
Exactly. It was not mocking anyone, except perhaps myself. I have a
habit of making posts that are too long and verbose, when the point
would have been clearer in a much shorter post. It's a bad habit. (And
I don't take any offence when someone points it out!)
Michael S <already5chosen@yahoo.com>: Jan 10 07:48AM -0800

On Tuesday, January 10, 2023 at 5:26:25 PM UTC+2, David Brown wrote:
> habit of making posts that are too long and verbose, when the point
> would have been clearer in a much shorter post. It's a bad habit. (And
> I don't take any offence when someone points it out!)
 
That applies even to this particular relatively short post.
Improved variant:
"I have a habit of writing posts. It is a bad habit."
Ben Bacarisse <ben.usenet@bsb.me.uk>: Jan 10 05:16PM

>> I have never said.
 
> Are you now trying to tell us that you haven't claimed your position
> is "uncontroversial" ? Seriously?
 
This has got out of hand! Juha has not claimed that all his opinions
are uncontroversial fact. I can state that, in my opinion, P =/= NP,
and I can claim that this opinion is uncontroversial, but you'd be wrong
to say that I am claiming that this opinion is uncontroversial fact.
 
I suspect you meant that Juha claims that his opinions are
uncontroversial as a matter of fact, not that they are "uncontroversial
fact".
 
<snip some details of Google's style guide>
Yes, Google's opinions on style are much closer to mine.
 
--
Ben.
David Brown <david.brown@hesbynett.no>: Jan 10 09:38PM +0100

On 10/01/2023 18:16, Ben Bacarisse wrote:
 
> I suspect you meant that Juha claims that his opinions are
> uncontroversial as a matter of fact, not that they are "uncontroversial
> fact".
 
That is a better way to put it. Facts should be uncontroversial, but
opinions can be uncontroversial without being known to be facts.
 
He has certainly said that he feels his opinions are uncontroversial,
which is quite odd considering how much controversy there has been in
this thread!
 
"Chris M. Thomasson" <chris.m.thomasson.1@gmail.com>: Jan 10 12:48PM -0800

On 1/9/2023 9:56 PM, Juha Nieminen wrote:
 
>> And if this post does not convince you, it is probably because it is too
>> long and too verbose - making it hard to read and understand.
 
> You can go fuck yourself as well.
 
Imvho, David did not deserve that. I have argued with David before and
never told him to f off or anything like that. ;^o
Bonita Montero <Bonita.Montero@gmail.com>: Jan 10 02:50PM +0100

Am 08.01.2023 um 23:55 schrieb Amine Moulay Ramdane:
 
> Please ignore this post of mine, since i have just posted it in the wrong forum.
 
You always post in the wrong forum.
Malcolm McLean <malcolm.arthur.mclean@gmail.com>: Jan 10 05:11AM -0800

On Monday, 9 January 2023 at 16:42:32 UTC, Bonita Montero wrote:
> alternative algorithm. You'd have a list of eligible numbers and
> randomly chose one of them. That would also take a lot of time to
> remove the number from the list.
 
Here's my go.
#include <random>
#include <vector>
#include <cstdio>
 
/*
Draw a enadom number form the hypergeomtric distribution (sampling
from a bi-valued population without replacement)
rndengine - a random number generator engine
Ngood - number of positives in the population
Nbad - number of negatives in the population
Nsample - number of samples to take (less than or equal to Ngood + Nbad)
Returns: the number of "good" elements drawn, randomly.
*/
template<class rndengine>
int rand_hypergeometric(int Ngood, int Nbad, int Nsample, rndengine &eng)
{
int answer = 0;
std::uniform_real_distribution<double> distr(0, 1);
for (int i =0; i < Nsample; i++)
{
double p = distr(eng);
if (p < ((double)Ngood)/(Ngood + Nbad))
{
answer++;
Ngood--;
}
else
{
Nbad--;
}
}
 
return answer;
}
 
/*
Recursive randunique function
out - vector to collect results
Nsamples - number of samples to take
Npopulation - size of population
indexbase - fiddle to have populations not starting from 0, pass 0 at top level.
eng - the random number engine
 
*/
template<class rndengine>
void randunique_r(std::vector<int> &out, int Nsamples, int Npopulation,
int indexbase, rndengine &eng)
{
if (Nsamples == 0)
return;
std::uniform_int_distribution<int> distr(0, Npopulation -1);
int i = distr(eng);
int Nsampleslow = rand_hypergeometric(i, Npopulation - i -1, Nsamples-1, eng);
randunique_r(out, Nsampleslow, i, indexbase, eng);
out.push_back(i + indexbase);
randunique_r(out, Nsamples - Nsampleslow -1, Npopulation - i -1, indexbase + i, eng);
}
 
/*
Draw a set of unique random samples from a population
Nsamples - the number of elemnts to choose.
Npopulation - the population size
eng - the random number engine
Returns: vector with indices of chosen members, sorted ascending.
*/
template<class rndengine>
std::vector<int> randunique(int Nsamples, int Npopulation, rndengine &eng)
{
std::vector<int> answer;
randunique_r(answer, Nsamples, Npopulation, 0, eng);
 
return answer;
}
 
int main(void)
{
std::mt19937 engine(123);
std::vector<int> result = randunique(10, 20, engine);
for (int i =0; i <result.size(); i++)
printf("%d, ", result[i]);
printf("\n");
 
return 0;
}
 
Not very efficient. But the rand_hypergeometric functon is written naively.
It can be rewritten to run a lot faster, though this isn't easy.
Malcolm McLean <malcolm.arthur.mclean@gmail.com>: Jan 10 05:19AM -0800

On Tuesday, 10 January 2023 at 13:11:27 UTC, Malcolm McLean wrote:
 
> randunique_r(out, Nsamples - Nsampleslow -1, Npopulation - i -1, indexbase + i, eng);
> }
Bug:: should be
indexbase + i + 1.
Sam <sam@email-scan.com>: Jan 09 08:31PM -0500

Corey White writes:
 
> the arrays. When I try to assign them dynamically I get
> segmentation faults. Could any of you geniuses help
> me out?
 
You will find std::vector down the hall, last door on your left.
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: