[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: DIGITP and DIGIT-WEIGHT



GJC's note about control constructs and macros really hit home.
I have, for some time, advocated that SOME way be found to
grab the value of a COND predicate neatly.  I've experimented
in SCHEME with things like
	(COND ((DIGITP X) => (LAMBDA (WEIGHT) (HACK WEIGHT 43)))
	      ...
and also thought of simply that a symbol after a predicate and before
anbother expression should get bound to the value:
	(COND ((DIGITP X) WEIGHT (HACK WEIGHT 43))
buit neither of these is very LISPy.  A similar idea would happen
to work for CASEQ:
	(CASEQ (DIGITP X) WEIGHT
	    ((0 1 2) (HACK WEIGHT))
	    ((3 4) (GROSS-OUT WEIGHT)) ...
But I'm not satisfied with these, and I bet no one else is, either.

The idea of an extra argument to macros is neat.  It would require
EVAL to keep track of these contexts, however--EVAL would probably
need the context as an extra argument also.  Maybe functions could get it,
too!  It's hard to know where to stop.  But this striked me as a quick
explicit patch [strikes], where one really wants is an optimizing
compiler as GJC described that would take care of these thinsg for you.
(For one thing, the macro expansion shown by GJC for an IF and DO
loop couldn't be done by a simple macro--you'd need continuations.)