ewh@druky.UUCP (HarkinsEW) (08/20/84)
re: long vs. short identifiers; it seems to me that with a bit of judiciousness, one can have it both ways: instead of doggoneid1 being confused with doggoneid2 in a truncating compiler, if you declare them like this: 1doggoneid and 2doggoneid, ie, make the unique part first instead of last, then you have portable long ids. see any holes kids? ernie harkins
steiny@scc.UUCP (Don Steiny) (08/21/84)
*** > instead of doggoneid1 being confused with > doggoneid2 in a truncating compiler, if you declare them > like this: 1doggoneid and > 2doggoneid, ie, make the unique part first instead of last, > then you have portable long ids. see any holes kids? ernie harkins A tiny hole, you may not start identifiers with numbers. Try: _1doggoneid _2doggoneid Or some such thing. Don Steiny Personetics 109 Torrey Pine Terr. Santa Cruz, Calif. 95060 (408) 425-0382 ihnp4!pesnta -\ fortune!idsvax -> scc!steiny ucbvax!twg -/
ron@BRL-TGR.ARPA (08/22/84)
From: Ron Natalie <ron@BRL-TGR.ARPA> Yeah, I see a problem. You can't begin identifiers with digits!
mwm@ea.UUCP (08/24/84)
#R:druky:-74000:ea:13500022:37777777600:981 ea!mwm Aug 23 17:02:00 1984 /***** ea:net.unix-wizar / druky!ewh / 5:34 pm Aug 20, 1984 */ re: long vs. short identifiers; it seems to me that with a bit of judiciousness, one can have it both ways: instead of doggoneid1 being confused with doggoneid2 in a truncating compiler, if you declare them like this: 1doggoneid and 2doggoneid, ie, make the unique part first instead of last, then you have portable long ids. see any holes kids? ernie harkins /* ---------- */ This is a cog-eng flavored problem, and exists outside of C. I first ran into it in FORTRAN, with the real, reliable 6-char names. Some user had exchanged (by accident) DVELX and DVELY in a routine call. He had just mis-read the names. If he had used XDVEL and YDVEL, the difference would have been obvious. Conclusion: Place the distinguishing part of near-identical names at the *front* of the name. This also helps avoid (but doesn't solve, as I've discovered) the variable variable-name length problem in C. <mike
toby@gargoyle.UChicago.UUCP (Toby Harness) (08/27/84)
> re: long vs. short identifiers; it seems to me that with a bit of > judiciousness, one can have it both ways: > instead of doggoneid1 being confused with > doggoneid2 in a truncating compiler, if you declare them > like this: 1doggoneid and > 2doggoneid, ie, make the unique part first instead of last, > then you have portable long ids. see any holes kids? ernie harkins That`s fine when one is writting new code, (and in fact should be considered necessary by any standard of good programming style) but it`s not so helpful when one is porting a piece of code who`s author gave no such consideration to unique identifers. I find myself spending too much time on the latter. Here is a short little script that I pass most 4.2 stuff through. #!/bin/sh # UNISRC_ID: @(#)cnam.sh 1.5 5/12/84 # printout C identifers greater that 15 characters # Toby Harness tmp=/tmp/cnam$$ tmpa=/tmp/cnama$$ trap 'rm -f $tmp $tmpa' 1 2 3 for i in $* do tr -cs '[a-z][A-Z][0-9]_' '[\012*]' < $i | grep '...............*' >> $tmp done sort -d $tmp | uniq > $tmpa fgrep `cut -c1-15 $tmpa | uniq -d` $tmpa rm $tmp $tmpa ------------------------------------------------ Note: The machines I deal with support 15 character external identifers. You may have to change the "grep" and the "cut" to fit your compiler/linker. Toby Harness Ogburn/Stouffer Center, University of Chicago ...ihnp4!gargoyle!toby