The following function aims to make a symbol out of several arguments. However, calling it generates a keyword error.
(defun create-symbol (&rest objects &key intern (package *package*))
"Creates a symbol from the objects."
(let ((arg-string (format nil "~{~A~^~}" (first objects))))
(if intern
(values (intern arg-string package))
(make-symbol arg-string))))
For example, (create-symbol "A" 1) produces Unknown &KEY argument: "A" instead of #:A1.
Also not sure if (first objects) is the correct way to access the &rest arguments, if no keywords are submitted.
Thanks for any help verifying the intended operation of this function.
Edit: Given the comments below, it looks like manual parsing of the arguments may be one way to go when they are combinations of the lambda list keywords &optional, &rest, and &key. The following function seems to do what I was originally intending:
(defun create-symbol (&rest objects&keys)
"Creates a symbol from the objects,
with optional keywords :intern and :package."
(let* ((keys (member-if #'keywordp objects&keys))
(objects (ldiff objects&keys keys))
(arg-string (format nil "~{~A~^~}" objects)))
(if (getf keys :intern)
(intern arg-string (or (getf keys :package) *package*))
(make-symbol arg-string))))
(create-symbol 'a :intern t)? How about(create-symbol :a :intern t)? How about(create-symbol :package :intern t)?