NP - Frank Miller's Charlie Brown
Glenn Scheper
glenn_scheper at earthlink.net
Thu Mar 19 13:02:39 CDT 2009
> sucked terribly at C language
I suck up C.
The key to C in my opinion is to memorize:
1. the precedence of binding order
(e.g, multiply/divide before add/subtract before shift before bitwise and/or ...)
2. whether things are evaluated from left to right, or right to left
(e.g, math is left to right, but pointers etc. are right to left)
I saw all that printed on the back cover of a small C book years ago. My C grail.
====
So for instance, in an absurd concoction, nut unlike my real coding:
*p++ += a/-b*2;
unary minus comes before multiply/divide;
multiply/divide comes before assignments;
multiply/divide are of equal binding order,
and evaluated L-to-R, so a/-b comes before that * 2
++ affects p and not *p, per #2.
====
Back in 1993 I aimed at saving editing keystrokes with terse names:
parse(int i) {
char * cp = runs + 5;
int j = 1;
while (*cp != ' ') {
j <<= 1;
j |= *cp++ & 1;
}
runs[2] = '\0';
printf(" 0x%04x,\n", j);
sp[i] = j;
runs += 19;
return 0;
}
====
By 1997 I thought I might be saving a few cpu cycles by avoiding
library calls, like doing all my own atoi and printf conversions,
and I was writing unreadable code using some of my....
//favorite idioms
#define in *into++ =
#define incrlf {*(short*)into = '\r' | '\n' << 8; into +=2;}
#define ineol *into = '\0';
#define ins(x) {char*cq=x; if((*into = *cq) != '\0') while((*++into = *++cq) != '\0'){}}
char * InTen(char * into, int n, char * text)
{
//advancing into, format count and text fixing '$'=pluralization
//input like 7 " Big ball$ ..."
//makes output " Seven big balls ..."
static char *cardinal[] = {
"No",
"One",
"Two",
"Three",
"Four",
"Five",
"Six",
"Seven",
"Eight",
"Nine",
"Ten",
};
char *from;
At(1307);
if(esc)Ape(); //nobody doing test would be in a very big hurry
while(*text == ' ') { //copy initial spaces
in*text++;
}
if(n < 11 && n > -1) { //spell out these numbers
from = cardinal [n];
*into = (char) (*from | *text & ' '); //may convert Seven to lower case
while((*++into = *++from) != '\0') {
}
} else {
into = InI(into, n); //use digits
}
in ' ';
from = text;
if(*from)
in (char)(*from++ | ' '); //lowercase B of Big
while ((*into = *from) != '\0' && *from != '$') {
++into;
++from;
}
if(*from) { //dollar sign
++from;
if(n != 1) {
if(from[-2] == 's') //loss$ -> losses
in 'e'; //make plurals
in 's'; //make plurals
}
while ((*into = *from) != '\0') {
++into;
++from;
}
}
ineol;
At(1308);
if(esc)Ape();
return into;
}
====
But now my syntax is simple, and long words
aim to constantly prop up my senix memory:
int Question_RETRAIN_at_DCS( )
{
if( ! ExhaustedAllDataRatesToTry )
{
RecordFact( QUESTION_RETRAIN_ANSWER_IS_YES );
return 1;
}
else
{
RecordFact( QUESTION_RETRAIN_ANSWER_IS_NO );
return 0;
}
}
... A routine called from only one place, itself simple, verbose:
case T_30_NODE_D_RESPONSE_TO_DCS_WAS_FTT:
ExitTestUnhappyAboutCFR( );
RecordFact( NOTE_THAT_FTT_IS_ALLOWED_HERE );
// Woe, I never wrote this rx FTT case code.
if( Question_RETRAIN_at_DCS( ) )
{
TryNewDataRateAfterRtnOrCtc = 1; // Oh. Or FTT, I am so forgetful.
{ TightLoops = 0; T30State = T_30_NODE_D_SET_MODE; }
TransmitCommandCounter = 0; // to enter T_30_NODE_D_SET_MODE
}
else
{
TransmitCommandCounter = 0; // for DCN signal
{ TightLoops = 0; T30State = T_30_NODE_C_TRANSMIT_DCN; }
}
break;
Now, about C++ ....
Yours truly,
Glenn Scheper
http://home.earthlink.net/~glenn_scheper/
glenn_scheper + at + earthlink.net
Copyleft(!) Forward freely.
More information about the Pynchon-l
mailing list