Sujet : Re: The joy of FORTRAN
De : bowman (at) *nospam* montana.com (rbowman)
Groupes : alt.folklore.computers comp.os.linux.miscDate : 01. Mar 2025, 05:35:48
Autres entêtes
Message-ID : <m2fh54F3tr0U1@mid.individual.net>
References : 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
User-Agent : Pan/0.160 (Toresk; )
On Fri, 28 Feb 2025 17:47:19 -0700, Peter Flass wrote:
Imported one C program that was all macros. In hindsight it would have
been better just to rewrite it.
The one I'm thinking of had gems like
#define STRF_FN_DECL(obj) \
size_t strf_##obj (char *obuf, size_t olen, const char *fmt, \
void *data, list_t *list)
#define STRF_FN(obj) \
STRF_FN_DECL(obj) \
{ \
static list_t llist; \
static struct obj##_struct o; \
\
if (list == NULL || list->data == NULL) { \
if ( data) { \
memcpy(&o, data, sizeof(o)); \
} else { \
memset(&o, 0, sizeof(o)); \
} \
if ( list ) { \
llist = *list; \
} \
llist.data = (void*)&o; \
list = &llist; \
} \
return (strfobj (list->data, list, obj##_map, obuf, olen, fmt)); \
}
#define MAP(nm,s,fmt,fn,sm, sfn) { #s, sizeof (#s)-1, \
offsetof (struct nm##_struct, s), fmt, fn, sm,
sfn }
Between the stringizing and concatenation operators good luck finding a
function that did stuff with foo. Using 4 characters was an extravagance;
most of his code didn't exceed 3 characters for variable names.
Now the irony: he had been a TA at UM and students who had him said he was
a stickler for well commented code. He personally never commented a line
of code as far as I could tell.