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

Re: Function invocation by key word

Your defun-keyed looks like a good thing.  It's too bad you didn't write
it several years ago, before we started putting keyword-argument
function in the Lisp Machine.  If you look at the current Lisp Machine
software system, there are a lot of functions that are called by
keyword, using the simpler mechanism of simply having a &rest argument
and having the function sort out the arguments.  An example in the manual
(from the Archaic Window System -- this function is highly obsolete)
is tv-define-pc-ppr.  The example is:

(setq foo (tv-define-pc-ppr "foo" (list fonts:tvfont)
                            ':top 300
			    ':bottom 400))

So the keyword names are evaluated (thus the single-quote characters),
and they are in the keyword package.  As I understand it, here is a
point-by-point comparison:

(1) With defun-keyed the user is saved the trouble of writing the single-quotes.
    He doesn't get to put forms there, but nobody ever does that anyway.
(2) With defun-keyed, the parsing is done at compile time instead of run time,
    resulting in faster execution.
(3) With defun-keyed, an actual argument position is created for every keyword
    option, and so function calls must always pass all those arguments.  This
    could result in slower execution speed.
(4) In the Lisp Machine, the keyword symbols have to be on the keyword
    package, but the names of the local variables have to be in the current
(5) The syntax is different from the one we use now for keyword arguments.

Points (1) and (2) are positive.  I don't know how much of a problem (3) and (5)
are.  (4) could be solved by having the defun-keyed macro expander re-intern
the symbols to create the keywords to be looked for; I think this would be OK.