Path: utzoo!attcan!uunet!cs.utexas.edu!usc!apple!well!oster From: oster@well.sf.ca.us (David Phillip Oster) Newsgroups: comp.sys.mac.programmer Subject: Re: THINK C Suggestions Message-ID: <21163@well.sf.ca.us> Date: 14 Oct 90 06:16:52 GMT References: <90283.224058CXT105@psuvm.psu.edu> Organization: Whole Earth 'Lectronic Link, Sausalito, CA Lines: 58 In article <90283.224058CXT105@psuvm.psu.edu> CXT105@psuvm.psu.edu (Christopher Tate) writes: >instead, why not just >extend C to have a construct similar to Pascal's WITH statement? Also, error reporting in THINK C. 1.) WITH statement. Don't kid yourself. you can write: register StructPtr myP; myP = *myHandle; myP->field1 = foo; myP->field2 = fum; ... Which is identical code to what the WITH statement generates anyway. But, it has these two colossal advantages: a.) it is explicit, you can see at a glance what things are fields of a handle and what things are variables. WITH statements generally make for code that will take you hours of puzzling out when you look at it next year. b.) it is explicit, you can see at a glance that myP->foo is a field in a structure, not a variable, and if you say something like: myP->width = StringWidth(myP->name); you can bet that it will crash because the function call will shift the heap and myP will dangle. WITH statements make it easier to forget that handles on the Mac can move, if they are not locked, depending on what function you call. (I would agree to add a WITH statement if it could be implemented in the EDITOR, so that I could choose on a case by case basis to see the full names of the fields or just the short names, depending on how well I remembered _that_ specific use.) 2.) Don't fool yourself. The reason THINK C stops at the first error is because if it were to continue the parse, it would need error recovery code. Most parsers are measurably slowed done by the presence of error recovery code even if they don't actually hit any errors (the stack frames in the parser get larger.) I want THINK C to compile correct code as fast as possible, since it compiles correct code so much more frequently than it compiles erroneous code. 3.) What I want is a mode like require prototypes, that instead produces a comile error every time it hits a statement that would need a cast if prototypes were turned off. For example: double sine(double); /* the presence of this prototype */ sine(3); /* should produce an error here, so I can edit it to: */ sine((double) 3); That way, I could turn on prototypes ONCE, add my casts, and then turn them off and get faster compiles. Since this is a fundamental flaw in the current C standard, I am unlikely to get my wish. -- -- David Phillip Oster - Note new signature. Old one has gone Bye Bye. -- oster@well.sf.ca.us = {backbone}!well!oster