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

ARRAYCALL vs FUNCALL



An opencoded ARRAYCALL should take about 5-10 JonlJiffies of time,
whereas a CALLF (the compilation of FUNCALL) would probably take at
least 100 JJ's.  I believe the reason PAULW used FUNCALL rather than
ARRAYCALL is that he wasn't sure that all of his "arrays" were indeed
arrays, or whetehr some of them were perhaps symbols with array
properties.  Maybe you could run a few tests, with all the 
   (FUNCALL <a> ...)
turned into something like
   (IF (EQ (TYPEP <a>) 'ARRAY) (ARRAYCALL T <a> ...) 
       (BREAK PAULW-LOSES-ON-FUNCALL))
Indeed, the maclisp interpreter permits you to FUNCALL any kind
of array, whether it be type T or FIXNUM or whatever;  if this
is the problem (instead of the potential for getting SYMBOLs as
arrays), and if speed is of the essence, then modulo multiple
evaluations of arguments (for which, see NILCOM;EVONCE >) you could
write something like
   (DEFMACRO FULLARRAYCALL (&REST L &AUX (A (CAR L)))
      `(CASEQ (ARRAY-TYPE ,a)
	      (FIXNUM (ARRAYCALL FIXNUM ,.l))
	      (FLONUM (ARRAYCALL FLONUM ,.l))
	      (T      (ARRAYCALL T ,.l))))
Currently, "ARRAY-TYPE" is not a primitive maclisp funciton,
although more than once we wish it were.  It could be defined as
   (DEFMACRO ARRAY-TYPE (A)
      `(EQ (CAR (ARRAYDIMS ,a)) 'ARRAY))
but for speed and non-CONSibility, we should write this one as
a hand-coded LAP subr.