Name: Anonymous 2015-07-27 20:45
... when C has function pointers?
struct fp
{
struct fp *(*func)(void *);
};
C doesn't even have a generic function pointer type on all implementationsI fail to see how a generic function pointer would be of use, but you can always return a void * that you then cast into a pointer to a struct that contains the function pointer you want.
void* (*fp)(...);
C doesn't even have a generic function pointer type on all implementations
void (*)()
// or anything really
The latest publically available version of the C11 standard is the document WG14 N1570, dated 2011-04-12. This is a WG14 working paper, but it reflects what was to become the standard at the time of issue.
People are using C when they should be using Pascal, Fortran, PL/I,Did you copypaste this from a 20 year old BBS?
C will not auto-coerce a long to a double (as a weakly typed language would)If the range of long is less than the range of double, why would this be "weakly typed" at all? It seems like you don't even know what that means. Also, C will do this.
void*
.*void
is 1) explicit, so definitely not weakly-typed 2) defeats the very point of types.JavaScript and PHP are, in fact, strongly typedNope, at least not completely strongly typed, and since they're so weak in the spots that matter most, they are, for most intents and purposes, weakly typed.
weak typing is when values have types but the language inserts all sorts of implicit conversionsThis is a redefinition by "scripting language" programmers to distinguish their language from Perl, not the original meaning of the term.
C's ability to cast to *void is 1) explicitIt is implicit, which is one of the incompatibilities with C++.
2) defeats the very point of types.From a strongly typed point of view, the only type C has is
unsigned char
. (This might help you understand the difference between strong and weak types.)This means it ultimately has no types, neither weak ones nor strong ones.Close, but it only has one type:
unsigned char
.Nope, at least not completely strongly typedIt's impossible to throw away the type of a value. They have no conversions either (since they have only one strong type, that's absurd). The "conversions" are really a dispatch hidden inside the built-in operators.
JavaScript and PHP are, in fact, strongly typed.Did you write that with a straight face? I doubt so.
Note that some of these definitions are contradictory, others are merely orthogonal, and still others are special cases (with additional constraints) of other, more "liberal" (less strong) definitions. Because of the wide divergence among these definitions, it is possible to defend claims about most programming languages that they are either strongly or weakly typed.
Java, C#, Ada and Pascal are sometimes said to be more strongly typed than C
Assembly language and Forth have been said to be untyped. There is no type checking; it is up to the programmer to ensure that data given to functions is of the appropriate type. Any type conversion required is explicit.
void *
values in C: it is up to the programmer to ensure that data given to functions is of the appropriate type. Thus, C is untyped, with optional static typing (whether it is strong or weak is up to debate). There is no type checking void * values in C: it is up to the programmer to ensure that data given to functions is of the appropriate type. Thus, C is untyped, with optional static typing (whether it is strong or weak is up to debate).This is the most stupid argument I've ever heard, please stop posting.
someIdiotsIdeaOfWhatAdditionMeans
. You can write your own addNumbers
and concatenateStrings
in JavaScript if you like and they can throw exceptions when values of the wrong types are passed in. You just can't give them the + syntax.