General CL question: get-setf-expansion
"Tim Bradshaw (as tfb at cley dot com)" <[email protected]>
| Newsgroups | gmane.lisp.lispworks.general |
|---|---|
| Message-ID | <[email protected]> |
I'm writing a macro I've wanted for a while, which looks like (defaulting <place> <value-form>). This: evaluates <place> for a value or values if it's nil it then evaluates (setf <place> <value-form>) and then returns the value or values of <place> again There are various options for fancier cases. To do this right, it needs not to evaluate subforms of <place> more than once, so, for instance, (defaulting (aref x (incf i)) 0) can do what it should. get-setf-expansion provides what I think I need to do this. The question is: does anything usable as a place to setf have to have a setf expansion, or is it allowed for things just to fall back to calling some presumed (setf x) function? I don't think it should be because if it was it would make writing a macro like this much harder, but I can't work out from the spec. Both LW and SBCL are empirically fine. Sub question: someone must have done this sort of thing, and I'm sure I can remember seeing things like it. I can't find one now though: is there some available equivalent? (Please don't tell me this is already in CL: I will die of shame.) --tim