Path: utzoo!attcan!uunet!lll-winken!lll-tis!helios.ee.lbl.gov!pasteur!ames!pacbell!att!ihnp4!poseidon!ech From: ech@poseidon.UUCP (Edward C Horvath) Newsgroups: comp.sys.mac.programmer Subject: Re: LSC almost gets it right. Message-ID: <496@poseidon.UUCP> Date: 9 Sep 88 17:53:43 GMT References: <3873@polya.Stanford.EDU> Organization: AT&T Information Systems, Lincroft, NJ Lines: 36 Earlier I wrote !What drives me NUTS about LSC prototyping... is the !SILENT coercion of (incorrect) arguments. Example: you pass 0 for the space !parameter to NewWindow. This is an error, folks, it needs to be NIL or NULL !or, in any case, a LONG zero. LSC is happy to silently notice that !the value ought to be long, and indeed generates code to push a long zero. From article <3873@polya.Stanford.EDU>, by kaufman@polya.Stanford.EDU (Marc T. Kaufman): ! Well, K&R says that '0' casts correctly to any NIL type. If you were using ! MPW, '0' would already be 32 bits. Syntax correctness does not imply semantic ! correctness. That's right. But a compiler that implements non-standard semantics, silently, is no longer a C compiler. An explicit cast a la K&R is fine by me, e.g. myPtr = 0; As is the casting incorporated into C++: one can overload a method to accept different types for the same positional parameter, and the cast then becomes explicit in the overloaded method implementation. But the only casting K&R, or anyone else to date, provide for function arguments is to promote integer types smaller than int to int (NOT long!) and to promote floating point types smaller than double to double. Nowhere will you find "cast each argument to whatever the prototype specifies." In particular, nowhere in K&R will you find any notion of DEMOTING longs to ints, nor will you find the notion of promoting (int) to (void *). Yes, I KNOW that the prototype gives the compiler all the information it needs to correctly DO that cast. And I'll stop objecting, assuming that I am WARNED about it. And I won't object at all when and if "coerce all arguments to prototype" is standard C. I'm not asking for much. Just that when you do me a favor, you let me know. I may not be able to afford it... =Ned Horvath=