quiroz@cs.rochester.edu (Cesar Quiroz) (01/13/88)
Both William Sommerfeld and Chris Torek propose handling compiler hints as assertions (not necessarily the assert macro, of course). As this was still an idea in the making, they offered no concrete syntax for it, as is reasonable at this stage. Thus, it would be unfair to criticize those ideas on syntactic grounds. Nevertheless, both proposals showed `freehand' examples of how it could work, and both examples were of the type I call "pointwise" in the discussion below. Just to make sure a point I made before doesn't get lost in the noise, let me insist that such hints are likely to need some indication of scope too. The models for hinting a C compiler (William Sommerfeld rightly notices that this belongs on the theory of hinting *any* compiler) that are in discussion are like this: `Pointwise': `Scoped': Assertions tell the compiler Assertions, as in the pointwise something it might not be able model, plus (optional?) scope of to figure out by itself. applicability. Ex: for (...;....;...) { Ex: for (...;....;...) { ...code... ...code... assertion,... assertion { ...code... .. code where assertion is } .. said to be valid } It is left to the compiler to ... code where assertion is propagate the information given, ... not guaranteed to be valid so it will presumably have to decide } when it ceases to be valid. The reason for recommending the scoping is precisely that these hints are useful when the compiler doesn't know how to figure them out by itself. It could hardly be expected to propagate this information, although it might be possible in some cases. For instance, when disambiguating array references by guaranteeing that two integer expressions are not equal, we are sparing the compiler having to solve Diophantine equations. So we can assume the compiler doesn't know how to solve such, how could it know if the given information holds in the next line? (Add adequate amounts of handwaving until this sounds likely). Chris Torek's "clean wound" principle sounds very sensible, but I suspect C is inhospitable to such extensions. The notation needed to express the class of hints that are interesting would be a programming language of higher level. Perhaps a good subject for comp.lang.misc. (To think that all this is just warm up for the day when we really know what `noalias' looks like :-) -- Cesar Augusto Quiroz Gonzalez Department of Computer Science ...allegra!rochester!quiroz University of Rochester or Rochester, NY 14627 quiroz@cs.rochester.edu