Strong Typing 
Author Message
 Strong Typing


>moved to comp.lang.misc

Moved back c.l.c/c++; I suggest followups only to comp.lang.c.


>> utter nothing at all...  In my opinion, (eg, GCC's) warnings are just
>> like errors, only they're called warnings, mostly because the compiler
>> can recover from them really well.)
>and because if they were errors, it wouldn't be C.

Many (all?) compilers claiming ANSI C conformance will accept the code:

        void f(int);
        void (*fp)(double) = &f;  /* legal ANSI C? */
        double d;
        char* p = &d;             /* legal ANSI C? */

with just a couple of warnings.  I used to think that it was legal
ANSI C.  Unless I'm misremembering, Andrew Koenig posted a while back
in c.l.c++ that such code is in fact NOT legal ANSI C.  If I'm wrong
about this, please let me know.  If I'm right, spread the word because
few people seem to know this.

So, the only cases where C++ is more strongly-typed than C is wrt
enums, void* conversions, and requiring prototypes.  There's nothing
in ANSI C stopping implementations from giving errors for the above
code (or from doing link-time type-checking of functions).

>> And I'd really like to hear why anyone would think that strong typing
>> could be construed as anything but an advantage.
>oh, sure.  when you're writing an OS.
>something that 0.01% of the people do, but 99.99% demand.

Can someone provide an example where strong typing in C "gets in the
way"?  I keep seeing statements that strong typing is a nuisance when
doing low-level programming, but I have yet to see actual examples.
In other words, what are some specific examples where
down-to-the-metal C programmers use casts (other than in qsort()
compare functions)?  This isn't an attack; I'm just trying to find the
source of this cliche.

Jamshid Afshar

Sat, 09 Mar 1996 11:35:24 GMT  
 [ 1 post ] 

 Relevant Pages 

1. Strong type checking...

2. Strong type checking ... (not really)

3. Strong type checking + Heterogenous con

4. Strong typed variables

5. Strong typing header needed

6. Strong type checking is good, but...

7. Escape from strong typing (was: swap(x,y))

8. Adding Strong Typing without adding to the Language

9. expressiveness and strong type system?


11. Strong typing



Powered by phpBB® Forum Software