In SBCL I enter a couple of constants and try to create an array like
this:
* (defconstant +rows+ 3)
+ROWS+
* (defconstant +columns+ 5)
+COLUMNS+
* (defparameter *my-array* (make-array '(+rows+ +columns+)
:initial-element nil))
debugger invoked on a TYPE-ERROR in thread #<THREAD "initial thread"
{9004381}>: The value +ROWS+ is not of type NUMBER.
Type HELP for debugger help, or (SB-EXT:QUIT) to exit from SBCL.
restarts (invokable by number or by possibly-abbreviated name):
0: [ABORT] Exit debugger, returning to top level.
(*)
0] 0
* (type-of +rows+)
(INTEGER 0 536870911)
*
This seems strange, since these two forms work:
(defparameter *my-array* (make-array '(3 5) :initial-element nil))
*MY-ARRAY*
* (defparameter *my-array* (make-array (list 3 5) :initial-element
nil))
*MY-ARRAY*
*
What nuance am I missing?
Thanks,
Sean
>>>>> "sw" == seanwinship <···········@yahoo.com> writes:
[...]
sw> What nuance am I missing?
When you quote as in '(foo bar) you are passing in a list of symbols.
Perhaps more examples will help?
CL-USER> (defun test (dimlist) (print dimlist) (print (first dimlist))
(print (second dimlist)))
TEST
CL-USER> (defvar a 1)
A
CL-USER> (defvar b 2)
B
CL-USER> (test '(a b))
(A B)
A
B
B
CL-USER> (test (list a b))
(1 2)
1
2
2
CL-USER> (test (quote (a b)))
(A B)
A
B
CL-USER> (test `(,a ,b))
(1 2)
1
2
2
cheers,
BM