Reputation: 1655
The problem with the following code is multiple evaluation:
(defmacro with-object (name &body body)
`(let ((,name (create-object)))
,@body
(free-object ,name)))
but I don't know how to do this the right way.
Upvotes: 1
Views: 53
Reputation: 529
In order to use name in the let binding in your code, it has to hold a symbol. There should be no multiple evaluation problem in the code you supplied, since the symbol held by name is just given a binding in the expansion and evaluated for the free-object call within the context of that binding.
Upvotes: 2