Menu

#14 Strange macro expansions

open
nobody
None
5
2005-07-07
2005-07-07
No

I'm not sure this is a bug or a feature but the
expansion of the macros header-slot-value,
reply-header-slot-value and the corresponding defsetf
forms depend on the header name parameter being a
literal keyword (and not on something that evaluates to
a keyword) or a literal string (and not on something
that evaluates to a string).

This means that the following code does not do what (I
think) it is supposed to do:

(let ((request (make-instance 'http-request))
(special-header :content-type))
(setf (reply-header-slot-value request :content-type)
"foo")
(setf (reply-header-slot-value request
special-header) "bar")
(reply-header-slot-value request :content-type))
->
"foo"

For a simpler example, consider:

(let ((request (make-instance 'http-request)))
(setf (reply-header-slot-value request :content-type)
"foo")
(setf (reply-header-slot-value request
':content-type) "bar")
(reply-header-slot-value request :content-type))
-> "foo"

Given the fact that these operators resemble normal
readers and writters (with normal function call
semantics), it might make bugs really difficult to
understand (at least, it did to me).

Best regards,

Antonio Leitao

Discussion


Log in to post a comment.