Path: utzoo!mnetor!uunet!dalcs!garfield!john13 From: john13@garfield.UUCP (John Russell) Newsgroups: comp.lang.c Subject: Re: Modern langauges Message-ID: <4369@garfield.UUCP> Date: 12 Jan 88 14:19:54 GMT References: <11072@brl-adm.ARPA> <519@gethen.UUCP> Reply-To: john13@garfield.UUCP (John Russell) Distribution: na Organization: Memorial University of Newfoundland, St. John's Lines: 58 In article <519@gethen.UUCP> farren@gethen.UUCP (Michael J. Farren) writes: >V4039%TEMPLEVM.BITNET@CUNYVM.CUNY.EDU (Stan Horwitz) writes: >>It's syntax is strange >>but that can be fixed to some extent by simply creating a file with >>#DEFINE statements defining thins in easier terms. > >This is an astoundingly bad idea. Doing this may result in the program >being more understandable for you (at least, until you learn C a little >better), but will make it damn near indecipherable for anyone else. I wonder about this. One of the uses I have for many #defines is often to create functions with short, mnemonic names that _I_ am comfortable with, then have verbose, self-explanatory symbolic names that automatically cast the types of paramaters. I can write programs for my own use quickly, or easy-to-understand code with a little more effort. I might even use "verbose" mode for a tricky section where I want to make sure I don't get lost. eg: #define forward(x) fd((double)(x)) /* move graphics cursor forward by some predefined amount (a la Logo) */ fd(distance) double distance; { ... } main() { double l1; int l2; short l3; long l4; ... assign some values to these variables ... /* I don't want to assume that everyone can follow my notation, so... */ forward(l1); forward(l2); forward(l3); forward(l4); } More readable to someone else, portable, and if I mix different types I don't have to worry about what type C will promote the result to. Of course this means I could pass a pointer without complaint, but you have to give the programmer *some* credit :-). John PS I'm sure once you've programmed a few operating systems this becomes academic. -- "Operating systems room, prepare for shutdown." "I never thought I'd be HAPPY to see our ratings do DOWN!" -- lots of these were sprinkled throughout the last broadcast episode of _Max_Headroom_