Correct usage of destructuring-bind
I'm experimenting with destructuring-bind as follows:
(destructuring-bind
(a b) '(1 2) (list a b)))
When I evaluate this in the REPL I get:
READ from #1=#<INPUT STRING-INPUT-STREAM>: an object cannot start with #\)
开发者_运维问答 [Condition of type SYSTEM::SIMPLE-READER-ERROR]
I expected the result to be
(1 2)
The error doesn't mean anything to me, in the context of the code above.
I realise that I'm just binding a simple list of arguments, rather than a tree, but I still expecteded this to work. Any clues as to where I've gone wrong?
Remove the extra ) on the end. Works fine.
While we are at it, the usual formatting is:
(destructuring-bind (a b)
'(1 2)
(list a b))
It also makes it easier to see how the parentheses match. Generally the editor will also help. Placing the cursor after a closing parenthesis should highlight the corresponding opening parenthesis. Also note that all self-respecting Lisp-syntax-capable editors have a command to find non-matching parentheses.
精彩评论