rfink@eng.umd.edu (Russell A. Fink) (10/11/90)
By rules of Kernighan and Ritchie, or standard adaptations of the language, can I nest comments within variable names? int number; . . . printf ("Value is %d", num/* this is obnoxious */ber); Is that obnoxious comment permitted, or is it syntactically wrong? Thanks in advance for response. -- //===== //===== Russ Fink =============== // //____ rfink@eng.umd.edu // // University of Maryland //===== //===== College Park ============
karl@haddock.ima.isc.com (Karl Heuer) (10/11/90)
In article <1990Oct10.211829.3168@eng.umd.edu> rfink@eng.umd.edu (Russell A. Fink) writes: >By rules of Kernighan and Ritchie, or standard adaptations of the >language, can I nest comments within variable names? > printf ("Value is %d", num/* this is obnoxious */ber); It's illegal (because comments are whitespace) in ANSI C. In Classic C it's illegal according to the book, but legal by common practice, so the practical answer is that it's implementation-dependent. Karl W. Z. Heuer (karl@ima.isc.com or harvard!ima!karl), The Walking Lint
ccplumb@spurge.uwaterloo.ca (Colin Plumb) (10/11/90)
In article <1990Oct10.211829.3168@eng.umd.edu> rfink@eng.umd.edu (Russell A. Fink) writes: > By rules of Kernighan and Ritchie, or standard adaptations of the > language, can I nest comments within variable names? > int number; > printf ("Value is %d", num/* this is obnoxious */ber); > Is that obnoxious comment permitted, or is it syntactically wrong? There are tricks I can play with the preprocessor to make it compile (#define num sizeof, for example), but by ANSI C rules, this must preprocess to printf("Value is %d", num ber); The old Reiser cpp did crunch comments down to nothing, concatenating tokens, and this was frequently used in wierd ways, e.g. #define ListOf(type) ListOf/**/type but this behaviour, while very common on Unix compilers, has always been non-portable. -- -Colin
gwyn@smoke.BRL.MIL (Doug Gwyn) (10/11/90)
In article <1990Oct10.211829.3168@eng.umd.edu> rfink@eng.umd.edu (Russell A. Fink) writes: >... can I nest comments within variable names? >printf ("Value is %d", num/* this is obnoxious */ber); That's not right -- a comment is replaced with in effect a single space.