C standard question?

  • Thread starter jan.chludzinski
  • Start date
C

Chris H

Willem said:
Chris wrote:
) In message <[email protected]>, Willem
)>Chris H wrote:
)>) In message <[email protected]>, Richard Bos
)>)>
)>)>> Do compilers still accept char unsigned? Some used to but I bet many
)>)>> don't now
)>)>
)>)>They had bloody better. You may not like it, but, like voting for Gordon
)>)>Brown, it's perfectly legal even if unusual and in some people's opinion
)>)>disgusting.
)>)
)>) Some one, elsewhere in this thread, did a search on "char unsigned" and
)>) go no hits at all.
)>)
)>) Has any one actually seen "char unsigned" used anywhere?
)>
)>Irrelevant.
)
) Why?

Because the C standard sais so. Whether it's used or not is irrelevant.

) If it is something no one has used and no one has seen used (and some
) people hare can remember back to the start of C) why is it still there?

Why bother to change the standard for something that isn't used anyway ?

Point taken.

It is just that it seems no one has ever seen it used.
 
K

Keith Thompson

Chris H said:
Why?

If it is something no one has used and no one has seen used (and some
people hare can remember back to the start of C) why is it still there?

Currently, the language states (C99 6.7.2p2) that "the type specifiers
may occur in any order, possibly intermixed with the other declaration
specifiers".

This rule allows silly things like "long unsigned long", "double
long", "long int unsigned long", and so forth. (I deliberately chose
examples that I *think* everyone would agree are silly.)

Changing this would require a more complicated set of rules, with the
risk that either the authors of the standard or some implementers
might get them wrong. Such a change could break existing code; it
would *definitely* cause some code that's currently legal to become
illegal. It would require a new revision of the C standard, along
with updates to textbooks, tutorials, implementations, and tools other
than compilers that parse C code. I can't guess how much effort would
be required, but I wouldn't be surprised if it were several
person-years. It would only infinitesimally increase the difficulty
of writing ugly C code. And those few programmers who like to write
"char unsigned" could safely continue to do so until C20?? compilers
replace compilers for earlier versions of the standard, something that
hasn't even happened for C99.

If I were designing a new language, I probably wouldn't permit that
particular kind of flexibility. (For that matter, the names of the
fundamental types would probably be single keywords or identifiers, so
the issue wouldn't arise in the first place.) But for an existing
language, I really don't think this minor flaw (which not everyone
even agrees is a flaw) is worth fixing.
 
R

Richard Bos

Jack Klein said:
On Wed, 7 May 2008 13:23:50 -0700 (PDT), Tomás Ó hÉilidhe


I would have a hard time believing that any people in the world other
than you write the ridiculous "char unsigned".

You may not believe it, but I have seen it. Rarely, and I don't remember
where, but I've seen it used.

And in any case, it is not relevant whether any of us believe that
anyone else would or would not write it that way 'round. It is allowed
to be written that way 'round, it is no less clear that way 'round
except for pure blind habit-boundness, and any programmer who has real
problems reading code which uses "char unsigned" instead of "unsigned
char" is considerably more ridiculous than the one who uses it - and, I
would say, a rather worse programmer for it as well.

Richard
 
C

Chris H

Richard Bos said:
You may not believe it, but I have seen it. Rarely, and I don't remember
where, but I've seen it used.

And in any case, it is not relevant whether any of us believe that
anyone else would or would not write it that way 'round. It is allowed
to be written that way 'round, it is no less clear that way 'round
except for pure blind habit-boundness, and any programmer who has real
problems reading code which uses "char unsigned" instead of "unsigned
char" is considerably more ridiculous than the one who uses it - and, I
would say, a rather worse programmer for it as well.

However it WILL cause problems as "everyone" uses the other way around.

I have seen people cause accidents where they were by pure bloody
mindedness technically right and the rest of the world did it
differently.

In this case the way "the whole world does it" is also technically
right.

Just being different for the sake of it and no other reason where there
is no advantage whatsoever and it flies in the face of normal
convention shows a very unprofessional programer who's ego is more
important than what he is doing.

Sorry I forgot this is C.L.C it is not connected to the real world where
real people are involved and incorrect software costs money and lives.
 
T

Thad Smith

Tomás Ó hÉilidhe said:
If you're too mentally retarded to answer that question correctly then
you'll probably too imcompetent of a programmer to read other people's
code.

I was enjoying reading Tomas's posts, partly because I share some of his
thoughts on portability and efficiency. This post, however, was beyond the
pale. I don't expect him to be a diplomat, but do expect decency.
 
P

Peter Nilsson

Flash said:
Tom�s � h�ilidhe wrote, On 10/05/08 18:55:



It is not a question about whether people can understand it, it is a
question about what they can understand fastest.

Which is probably why many successful programmers avoid C.
No matter who the author, even simple programs can look like
a dog's breakfeast compared to other languages. Just look at
the mixing of identifier styles in the standard library itself.
The brain is a truly wonderful pattern matching system,
and almost all C programmers brains are trained to match against
the pattern "unsigned char" rather than "char unsigned".

A better word would be conditioned.
So by going against convention you are forcing people to stop
using the fast method of gaining the information and switch to a
far slower method.

Which need not be as bad as it sounds.

I'm conditioned to recognise caucasian faces more easily than
oriental ones. But that says more about my conditioning than it
does about caucasions and orientals.
When you have to review a few thousand lines of code
written by someone else you will start to appreciate convention,
and as the amount of code goes up you will appreciate it more
and more.

On the contrary, its precisely this form of conditioning that
that is the bane of QA. The fast recognition you mention is
is used as tool of dismissal, not a tool of assessment. It
becomes all too easy to overlook code simply because it
it fits the 'style'. C is is notorious for common mistakes that
go unrecognised and unreported.
Oh, and if you want to discus C then insulting intelligent
experienced and even expert C programmers is not the best
way to go about it.

Learning to ignore intended insults _from_ the otherwise
intelligent experience and even expert C programmers
doesn't hurt either. ;-)
 
C

Chris H

I was enjoying reading Tomas's posts, partly because I share some of
his thoughts on portability and efficiency. This post, however, was
beyond the pale. I don't expect him to be a diplomat, but do expect
decency.

He appears to be enthusiastic but young, very inexperienced , (one MCU,
one compiler and a PC) and ABSOLUTELY CERTAIN of what he knows.

He takes as, many enthusiastic young and inexperienced people do, the
things he knows a s absolutes and sees in black and white. No shades of
grey.

Sadly he does not learn from those who are more experienced and reacts
badly to being told things that contradict. A little knowledge (as in
his case) is only dangerous when you don't accept that it is a little
knowledge (and may be flawed).

He has managed to argue in both c.l.c and comp.arch.embedded and tell
most of the experts in both they are wrong. Not a good way to start.
Also, very unfortunately , he has appeared to take the same stance with
employers.

Hopefully he will learn before he walks out of yet another job and
becomes unemployable in the industry he wants to work in.
 
F

Flash Gordon

Peter Nilsson wrote, On 17/05/08 06:41:
Which is probably why many successful programmers avoid C.
No matter who the author, even simple programs can look like
a dog's breakfeast compared to other languages. Just look at
the mixing of identifier styles in the standard library itself.

You should see some of the dog's breakfasts I've seen in Pascal!
Although I will admit that C gives you a lot more possibilities.
A better word would be conditioned.

Well, a lot of people already use hair conditioner...
Which need not be as bad as it sounds.

I'm conditioned to recognise caucasian faces more easily than
oriental ones. But that says more about my conditioning than it
does about caucasions and orientals.

If you are in a long queue at immigration and it is going slowly because
it takes the immigration officers longer to check peoples faces against
their passports you will appreciate that whilst it says nothing about
the orientals it does say something about what can be checked quickly.
On the contrary, its precisely this form of conditioning that
that is the bane of QA. The fast recognition you mention is
is used as tool of dismissal, not a tool of assessment. It
becomes all too easy to overlook code simply because it
it fits the 'style'. C is is notorious for common mistakes that
go unrecognised and unreported.

It varies. If from the code you can see the correct type for a variable
is char rather than unsigned char and you look up quickly to check
because you are not used to "char unsigned" you might miss that it is
declared as it is not what you are used to seeing!

In any case, my experience is that not having to deal with needless
inconsistency with common convention allows me to put more effort on
understanding what the code is doing and so spot more errors in the same
amount of time.
Learning to ignore intended insults _from_ the otherwise
intelligent experience and even expert C programmers
doesn't hurt either. ;-)

Very true.
 
D

David Thompson

In message
... Why would a compiler not compile something [standard...]

Why should it? There is no requirement anywhere (afaik) to have a fully
comforting compiler. <snip>

Even though it's only May, I'm already putting that in the running for
Best Typo* of the Year. (* or perhaps Spilling-Chucker-o?)

- formerly david.thompson1 || achar(64) || worldnet.att.net
 

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

Forum statistics

Threads
473,774
Messages
2,569,598
Members
45,159
Latest member
SweetCalmCBDGummies
Top