Pedants

K

Keith Thompson

Richard Heathfield said:
I prefer to get the relatively unimportant things right to start with, so
as to avoid wasting my pedant's time on trivia.
[...]

I've always assumed that you're your own pedant.
 
C

CBFalconer

Serve said:
The compiler would have flagged that long before it arrives there if
NULL is defined as ((void *)0)

But it isn't on the system he is using _now_. It will be on the
system he (or the victim) uses _tomorrow_.
 
C

CBFalconer

Serve said:
yes and since C99 is also C and there is nothing in the coding
standards that mentions that you *must* use C89 its legal.

That depends on the usage. For example:

int i;
int *p;

i = NULL; /* may pass, but illegal */
i = 0; /* OK */
p = 0; /* OK */
p = NULL; /* OK */
 
K

Kaz Kylheku

yes I thought about portability when declaring variables in the middle of a
function and decided to do it. That makes it all the more frustrating when
you have to discuss it again. On top of that, we're switching to Python soon
anyway :p




No thats too easy. These things easily add up to weeks of extra works
because almost every change needs testing too. I prefer to deliver my code
on time instead of constantly changing relatively unimportant things

If you turn off all compiler warnings, you can save even more time!

I take it you'd never use a lint program; that can produce more time-
wasting spewage in a minute than a pedant can produce in a week.
 
K

Kaz Kylheku

Using 0 instead of NULL is a matter of opinion though, its both correct.

That's true, and knowing this perhaps makes you more of a language
pedant than your fake pedant.

Only if the project has a set of written coding guidelines, and those
guidelines call for the use of NULL rather than 0 (or vice versa) then
he's right.

Someone who imposes his own pet coding preferences during a code
review (or worse, believes that they are language rules) isn't a
pedant, but a buffoon.
The readability of declaring 3 ints on 1 line or on 3 is opinion.
It has nothing to do with care. If a pedant starts worrying about that,

... he is not the sort of pedant we are discussing here. Doh?
 
S

Serve Lau

"Kaz Kylheku" <[email protected]> schreef in bericht
Using 0 instead of NULL is a matter of opinion though, its both correct.
That's true, and knowing this perhaps makes you more of a language
pedant than your fake pedant.

as im sure you remember from the first post a pedant is:

1. a person who makes an excessive or inappropriate display of learning.

actually knowing some rules does not make you a pedant.
 
L

lawrence.jones

Keith Thompson said:
(I've actually seen NULL used where '\0' would be more appropriate.)

I've actually seen NULL (mis)used for all flavors of 0. It seems to be
a very common mistake in environments where it's defined as just 0
rather than as (void *)0 and there is a shortage of pedants.

-- Larry Jones

My dreams are getting way too literal. -- Calvin
 
S

Serve Lau

Richard Heathfield said:
Serve Lau said:


How many rules must you know before you become a pedant?

Theres no limit as long as you dont "make an excessive or inappropriate
display of learning". its not hard to understand.

A kung fu master does not kick everybody's ass either
 
C

Chris H

I disagree totally. I have had a pedant as code reviewer and he always
got stuck in language issues never finding real bugs. Things like I
wasnt allowed to declare variables in the middle of a function or write
NULL or 0. The software never got better


That is not language issues but coding standard issue.
Very important and they do reduce bug count.
 
R

Rui Maciel

A kung fu master does not kick everybody's ass either

As it's already been asked before, if your problem consists of getting
your ass kicked too frequently then why not learn some kung fu to begin
with? I mean, you already confessed that not only you are aware that you
do write some no-nos but they are also constantly pointed out to you. So,
why not take a moment to learn to avoid those no-nos instead of whining
about those evil know-it-alls that have the nerve to point out your
flaws?


Rui Maciel
 
S

Serve Lau

Richard Heathfield said:
I don't know of anyone in this group who is a kung fu master. Neither do I
know of anyone in this group who has ever administered kicks to a member
of the species Equus asinus. So it's hard to see how relevant your point
is. But even if I'm to take it as an analogy, it seems inappropriate. If
you can think of any C expert in this group who is not prepared to be
patiently informative and helpful to those who are ready and willing to
learn about C, you are probably being over-critical of that C expert based
on a poor sampling. I am constantly amazed by how much time some people
here spend on helping others to learn their language, and by how much
patience they show in the face of infantile criticism by the ignorant.

Try to keep context. This is not about clc! Showing some knowledge here is
not inappropriate is it. I was just reacting to somebody calling me a pedant
because I know the difference between NULL and 0 while I never spread the
religion on what to use best and why.
 
S

Serve Lau

Rui Maciel said:
As it's already been asked before, if your problem consists of getting
your ass kicked too frequently then why not learn some kung fu to begin
with? I mean, you already confessed that not only you are aware that you
do write some no-nos but they are also constantly pointed out to you. So,
why not take a moment to learn to avoid those no-nos instead of whining
about those evil know-it-alls that have the nerve to point out your
flaws?

Whats pointed out? Maybe enlighten us whats best to use. NULL or 0?
 
L

lawrence.jones

Richard Heathfield said:
I don't know of *anyone* in this group who makes excessive or inappropriate
displays of learning where the C language is concerned.

Indeed, excessive or inappropriate displays of *ignorance* are far more
common. ;-)

-- Larry Jones

Everybody's a slave to routine. -- Calvin
 
N

Nick Keighley

"Kaz Kylheku" <[email protected]> schreef in berichtnews:[email protected]...

The compiler would have flagged that long before it arrives there if NULL is
defined as ((void *)0)

Coincidentally, I'm just removing lots of
int i = NULL;

from some legacy code I'm porting.
Perhaps a tougher review on the original code
would have saved me the trouble.
 
S

santosh

Nick said:
berichtnews:[email protected]...

Coincidentally, I'm just removing lots of
int i = NULL;

from some legacy code I'm porting.
Perhaps a tougher review on the original code
would have saved me the trouble.

Is there any reason at all to assign a null pointer constant to an int?
Why would anyone do this instead of using 0?
 
K

Kaz Kylheku

"Kaz Kylheku" <[email protected]> schreef in bericht


as im sure you remember from the first post a pedant is:

1. a person who makes an excessive or inappropriate display of learning.

I recall from the root article that a disjunction of three possible
definitions was given. By the above branch, nobody is a pedant during
a code review, because display of all pertinent learning is required.
In that situation you're an expert, and as such you're being paid for
what you know, and so you have to deliver.

A commercial lint program can generate thousands of diagnostics even
for a fairly small project. Many of those diagnostics are not useful
in the given situation, so the tool has to be iteratively configured
to improve its yield. People pay for tools like this and expect them
to have a large diagnostic base.

A pedant can also be configured that way. For instance, if I am told
``this code deliberately uses non-standard escape sequences in string
and character literals, please ignore'', then I will no longer flag
such uses.
 
R

Richard Bos

pete said:
Richard said:
Why? Would you normally do

int i='\0';

rather than

char c='\0';
int i=0;
void *p=NULL;

For
char *a = {STRING};
in a context of doing something
like what the ctype functions do,
do you prefer
if (a[x] > 0)
or
if (a[x] > '\0')
?

No, but in that case, a[x] _is_ a char, not an int. The discussion was
about assigning NULL (or the NUL character) to an int, not to any kind
of integer including the rather special char.

Richard
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,754
Messages
2,569,521
Members
44,995
Latest member
PinupduzSap

Latest Threads

Top