Why is C compiler stubborn ?

G

goose

It seems that none of you have ever read a Pascal or Delphi manual !!

Seeing as how we discuss only the C language here, I wonder
how you could consider that statement to be relevant at all.
 
B

Bob Martin

in 724501 20070315 080211 goose said:
Seeing as how we discuss only the C language here, I wonder
how you could consider that statement to be relevant at all.

Please read the thread before replying. At least two people said they had
never heard of the term "typecast" being used in ANY programming language.
 
Y

Yevgen Muntyan

Flash Gordon wrote:
....
I've yet to see a good reason why one should use the term typecast
instead of cast. A beginner at programming won't know either term so
learning the correct terminology for C is no hardship in this case, and
someone more experienced who has come across the term typecast is highly
unlikely to be confused by C books using the term cast.

So far I have only seen the term typecast used by people who do not know
the language and in resources which are bad for other reasons. So I
think the only reason some beginners use it is that they are learning
from poor resources, and the use of the word typecast is a good
indicator that the person using it has a poor knowledge of C even if the
person using it is the author of a book on C.

Take a look at this:
http://www.cs.cf.ac.uk/Dave/C/node9.html#SECTION00930000000000000000

Is it a bad one? It's listed at http://www.iso-9899.info/wiki/Main_Page.

Yevgen
 
R

Richard Heathfield

Bob Martin said:
Please read the thread before replying. At least two people said they
had never heard of the term "typecast" being used in ANY programming
language.

I hadn't, either - except (erroneously) in C and, later, C++.

So I hauled five language texts at random from my shelf, non-critically
(I didn't validate for whether I liked the described languages, or
indeed the authors!) and glanced through their indices:

"Programming with PASCAL" (Konvalina & Wileman, 1987). I found no entry
for "typecast".

"The Java Programming Language" (Arnold, Gosling, and Holmes, 2000). The
entry "type casting" does appear, but I could not find the word
"typecast" itself. "Type casting" is, of course, to "typecast" as
"operator overloading" is to "operatoroverload".

"Perl in a Nutshell" (Siever, Spainbour & Patwardban. 1999). I found no
index entry for "typecast".

"The C++ Programming Language" (Stroustrup, 2000). I found no index
entry for "typecast".

"PHP and MySQL" (Ullman, 2005). An entry exists for "type casting" (see
above), but nothing under "typecast" or "typecasting".
 
F

Flash Gordon

Richard Bos wrote, On 15/03/07 10:25:
When it says: "A good rule to follow is: If in doubt cast."!? That's not
bad, that's irretrievably rotten.

So my usage of typecast as an indicator of poor knowledge stands
unchanged. I did look at the page and I agree with Richard Bos. I would
have done something about that link on the Wiki (probably added a note
on the talk page) but they made it too difficult.
 
B

Bob Martin

in 724514 20070315 094232 Richard Heathfield said:
Bob Martin said:


I hadn't, either - except (erroneously) in C and, later, C++.

So I hauled five language texts at random from my shelf, non-critically
(I didn't validate for whether I liked the described languages, or
indeed the authors!) and glanced through their indices:

"Programming with PASCAL" (Konvalina & Wileman, 1987). I found no entry
for "typecast".

"The Java Programming Language" (Arnold, Gosling, and Holmes, 2000). The
entry "type casting" does appear, but I could not find the word
"typecast" itself. "Type casting" is, of course, to "typecast" as
"operator overloading" is to "operatoroverload".

"Perl in a Nutshell" (Siever, Spainbour & Patwardban. 1999). I found no
index entry for "typecast".

"The C++ Programming Language" (Stroustrup, 2000). I found no index
entry for "typecast".

"PHP and MySQL" (Ullman, 2005). An entry exists for "type casting" (see
above), but nothing under "typecast" or "typecasting".

Google for typecast shows 961,000 hits, including most Borland sites on
Delphi and Object Pascal.

It has been around for at least 25 years and I find it hard to believe that there
are serious programmers who have never come across it.
 
P

pete

Bob said:

N869
6.5.4 Cast operators
[#4] Preceding an expression by a parenthesized type name
converts the value of the expression to the named type.
This construction is called a cast.

6.3.2.3 Pointers
[#3] An integer constant expression with the value 0, or
such an expression cast to type void *, is called a null
pointer constant.
 
F

Flash Gordon

Bob Martin wrote, On 15/03/07 19:03:
Google for typecast shows 961,000 hits, including most Borland sites on
Delphi and Object Pascal.

It has been around for at least 25 years and I find it hard to believe that there
are serious programmers who have never come across it.

The work is obviously a far larger place than you had believed. Probably
for the 1st 10 years of my professional career I had never needed to do
any forced conversion between types apart from the odd use of 'ord' and
the 'chr' in Pascal (if I've remembered the function names correctly).
Since I always considered the ability to mix floating point and integer
types to be natural I never even thought about whether there was some
specific general term for such conversions. Then I first came across the
need to force type conversions it was in C and K&R use the term cast, so
that is the term I use. So whilst it is *possible* I had heard the term
typecast and forgotten it, it is definitely true that it was not in
anything like regular use anywhere I've worked in the past 20 years.
 
B

Bob Martin

in 724622 20070316 000018 Flash Gordon said:
Bob Martin wrote, On 15/03/07 19:03:
The work is obviously a far larger place than you had believed. Probably
for the 1st 10 years of my professional career I had never needed to do
any forced conversion between types apart from the odd use of 'ord' and
the 'chr' in Pascal (if I've remembered the function names correctly).
Since I always considered the ability to mix floating point and integer
types to be natural I never even thought about whether there was some
specific general term for such conversions. Then I first came across the
need to force type conversions it was in C and K&R use the term cast, so
that is the term I use. So whilst it is *possible* I had heard the term
typecast and forgotten it, it is definitely true that it was not in
anything like regular use anywhere I've worked in the past 20 years.

You obviously didn't write serious Pascal code ;-)
 
C

Chris Dollin

Bob said:
You obviously didn't write serious Pascal code ;-)

Do linkers [1] and functional-language interpreters [2]
count as serious?

[1] Actually a linking assembler, linking the assembler output
from the back-end of a compiler compiling a Pascalesque
language into loadable code.

My current recollection of the code is that there were
parts that were truly horrible ...

[2] Front-end compiled to combinator code a la Turner; back
end executed it; later versions used supercominators a la
Hughes.
 
F

Flash Gordon

Chris Dollin wrote, On 16/03/07 10:25:
Bob said:
You obviously didn't write serious Pascal code ;-)

Do linkers [1] and functional-language interpreters [2]
count as serious?

<snip>

Or circa 50000 lines of test rig software controlling lots of external
hardware for testing yet more external hardware. Or some nice big
embedded systems. Just to name a few :)
 
C

Charlton Wilbur

p> http://dictionary.reference.com/search?q=typecast

Dictionaries exist to record common usage, even when incorrect. Good
dictionaries indicate when a usage is considered archaic or incorrect;
bad ones don't. Only the most comprehensive dictionaries will include
definitions of technical jargon, and the theatrical and typographic
definitions of "typecast" are likely to be far more common anyway.
Finally, absence of evidence is not evidence of absence: the lack of a
technical definition for "typecast" in the dictionary does not mean
that the word does not have that meaning.

That said, it's been pretty conclusively established in this thread
that the correct term in C is "cast," while Delphi and Object Pascal
use "typecast." Given that we're discussing C, then, "cast" is the
correct form, but "typecast" is unambiguous. Is there any reason to
beat the horse further?

Charlton
 
K

Keith Thompson

Bob Martin said:
You obviously didn't write serious Pascal code ;-)

I've certainly written serious Pascal code, and I've never seen or
heard the word "typecast" applied in a Pascal context.

(I've never used Delphi and Object Pascal, though.)
 
B

Ben Pfaff

Keith Thompson said:
I've certainly written serious Pascal code, and I've never seen or
heard the word "typecast" applied in a Pascal context.

(I've never used Delphi and Object Pascal, though.)

It's a Turbo Pascal invention that came about around the release
of Turbo Pascal 4.0, c. 1987. (It might have been the 5.0
release, I'm not sure.)
 
B

Bob Martin

in 724816 20070316 203232 Keith Thompson said:
I've certainly written serious Pascal code, and I've never seen or
heard the word "typecast" applied in a Pascal context.

(I've never used Delphi and Object Pascal, though.)

What's with all you people rushing forward to boast of your ignorance?
Your not having come across "typecast" proves nothing.
 
K

Keith Thompson

Bob Martin said:
What's with all you people rushing forward to boast of your ignorance?
Your not having come across "typecast" proves nothing.

We're not boasting of our ignorance. We're refuting your apparent
claim that anyone who as written "serious Pascal code" must therefore
be familiar with the term.

I've come across the term "typecast", just not in the context of
Pascal.

Not that any of this either matters or is topical, of course.
 
B

Bob Martin

in 724933 20070317 092551 Keith Thompson said:
We're not boasting of our ignorance. We're refuting your apparent
claim that anyone who as written "serious Pascal code" must therefore
be familiar with the term.

You are not refuting anything - though you might be trying.
 

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,770
Messages
2,569,584
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top