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

Un-named arrays



You should not be using the (ARRAY <name> <type> <subscript1> ...)
but instead use the syntax:

		(SETQ MYARRAYVARIABLE (ARRAY NIL T n))

is what you want. The idea of putting things on the property list
is semantically hideous anyway since it cannot be bound. Put the object
only in the value cell and you will be much better off...

		(ARRAY () type dim1 dim2 ...)

returns an array object rather than putting it on the property list.
You can call this array by doing

	(ARRAYCALL type arrayobject subscript1 subscript2 ...) and you can 

store into it with

	(STORE (ARRAYCALL type arrayobject subscript1 ...) val)

If you dislike using arraycall, define a macro to handle the calling.
Eg, here is a sample piece of code using this scheme...

; Define (FOO sub1 sub2 ...)  to mean (ARRAYCALL T FOO sub1 sub2 ...)

(DEFUN FOO MACRO (X) `(ARRAYCALL T ,@(CDR X))) 

(DEFUN BAR ()
       (LET ((FOO (ARRAY () T 10.))) ; Create a 10-length T-type array in FOO
	    (BAZ FOO)		     ; Call some function BAZ with FOO array
	    (DO ((I 0. (1+ I)))      ; Loop I 0,1,...
		((= I 10.))	     ;  thru I=9
		(PRINT (LIST I (FOO I)))))) ; Printing (i foo[i])

;;; Initialize ARRAYOBJECT to a bunch of random values

(DEFUN BAZ (ARRAYOBJECT)
       (DO ((I 0. (1+ I)))
	   ((= I 10.))
	   (STORE (ARRAYCALL T ARRAYOBJECT I) (RANDOM))))