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

Antecedents



Bill,
   Granted that it's a pain to ahve to name trivial quantities
you only want to use twice, nevertheless I dispute the claim that
"LISP is guiltier than machine language" for the example described:
    Suppose (F a) is any function, (G a b) is a recursive function,
    and x stands for a large (or costly) expression.  Now suppose
    you want (G x (F x))) (or just (G x x)).  In machine language,
    (and presumably in the compiler's model), the second x is
    readily available in a register or arg vector or stack as
    part of the setup to call G, but in LISP there seems to be no
    way to exploit this, necessitating the invention of a
    temporary.
    ...
    Reservation:  a numeric designator ("N args ago") is unflavorful
    on grounds of readability and editability, hatching gross bugs
    on failure to increment or decrement the Ns upon insertion or
    deletion of intervening args.
As a rule, in machine language you must give *everything* a name
(for the most part, what is a register but a pronoun, or at least a
short name?); thus you don't notice it expecially when a trivial
intermediate quantity gets a name also.  For PDP-10 MacLISP:
	HRRZ A,@.SPECIAL FOO		;(BAR (CADR FOO) 'QUUX (CADR FOO))
	HLRZ A,(A)
	MOVEI B,.QUOTE QUUX
	MOVEI C,(A)			;Copy first arg to third
	PUSHJ P,BAR
Here we easily grabbed the first argument to copy into the third, but
that's because it had the name A!  (We gave the new one the name C --
or rather, the calling conventions *require* that we name the third
argument C.)

A partial exception is stack quantities, which don't have names,
but those are then generally accessed by numeric designator.
	PUSH P,[RETADR]
	HRRZ A,@.SPECIAL FOO		;Same example, but BAR is LSUBR
	HLRZ A,(A)
	PUSH P,A
	PUSH P,[.QUOTE QUUX ]
	PUSH P,-1(P)			;Copy first arg to third
	MOVNI T,3
	JRST BAR
RETADR:
Here we had to use a numeric offset to refer to the first argument.

In summary, I suggest that LISP probably lets you elide more names
than typical machine code, and lets you choose your own names for the
rest, rather than requiring a fixed small set of register names.
--Guy