[pro] [Q] introspecting setf expanders
Hello, I cannot find a standard way to figure out whether a setf expander has been defined for a symbol FOO (via either DEFSETF or DEFINE-SETF-EXPANDER). Is there one? Otherwise, I would also be happy with an SBCL-only solution. Thank you ! -- Resistance is futile. You will be jazzimilated. Scientific site: http://www.lrde.epita.fr/~didier Music (Jazz) site: http://www.didierverna.com
On Oct 8, 2012, at 15:28 , Didier Verna <didier@lrde.epita.fr> wrote:
Hello,
I cannot find a standard way to figure out whether a setf expander has been defined for a symbol FOO (via either DEFSETF or DEFINE-SETF-EXPANDER).
Is there one? Otherwise, I would also be happy with an SBCL-only solution.
Thank you !
#'get-setf-expansion, perhaps?
Raymond Wiker <rwiker@gmail.com> wrote:
#'get-setf-expansion, perhaps?
Nope, because it gives you something by default. CL-USER> (get-setf-expansion '(not-previously-defined)) NIL NIL (#:NEW886) (FUNCALL #'(SETF NOT-PREVIOUSLY-DEFINED) #:NEW886) (NOT-PREVIOUSLY-DEFINED) -- Resistance is futile. You will be jazzimilated. Scientific site: http://www.lrde.epita.fr/~didier Music (Jazz) site: http://www.didierverna.com
Just guessing: If you see that the writer form is a funcall to a setf function, you can then check with fboundp if such a function actually exists. This is probably a bit shaky, but maybe good enough for practical purposes? Pascal On 8 Oct 2012, at 16:56, Didier Verna <didier@lrde.epita.fr> wrote:
Raymond Wiker <rwiker@gmail.com> wrote:
#'get-setf-expansion, perhaps?
Nope, because it gives you something by default.
CL-USER> (get-setf-expansion '(not-previously-defined)) NIL NIL (#:NEW886) (FUNCALL #'(SETF NOT-PREVIOUSLY-DEFINED) #:NEW886) (NOT-PREVIOUSLY-DEFINED)
-- Resistance is futile. You will be jazzimilated.
Scientific site: http://www.lrde.epita.fr/~didier Music (Jazz) site: http://www.didierverna.com
_______________________________________________ pro mailing list pro@common-lisp.net http://lists.common-lisp.net/cgi-bin/mailman/listinfo/pro
-- Pascal Costanza
Pascal Costanza wrote:
Just guessing: If you see that the writer form is a funcall to a setf function, you can then check with fboundp if such a function actually exists. This is probably a bit shaky, but maybe good enough for practical purposes?
Good idea. To be more precise: - if the writer form is something else than (FUNCALL #'(SETF FOO) ...) then there is a defsetf going on (it even takes precedence over a potential setf function). - if the writer form is (FUNCALL #'(SETF FOO) ...) and that function is bound, then there is a setf function going on but no defsetf. - otherwise, there is no writer at all. I think this might just work. -- Resistance is futile. You will be jazzimilated. Scientific site: http://www.lrde.epita.fr/~didier Music (Jazz) site: http://www.didierverna.com
On Mon, 08 Oct 2012 17:38:42 +0200, Didier Verna said:
Pascal Costanza wrote:
Just guessing: If you see that the writer form is a funcall to a setf function, you can then check with fboundp if such a function actually exists. This is probably a bit shaky, but maybe good enough for practical purposes?
Good idea. To be more precise:
- if the writer form is something else than (FUNCALL #'(SETF FOO) ...) then there is a defsetf going on (it even takes precedence over a potential setf function).
- if the writer form is (FUNCALL #'(SETF FOO) ...) and that function is bound, then there is a setf function going on but no defsetf.
- otherwise, there is no writer at all.
I think this might just work.
As Pascal said, it's a bit shaky. E.g. a user could define (defsetf foo (x) (y) `(funcall #'(setf foo) ,y ,x)) which gives a false negative. Also, it won't be portable, because the (FUNCALL #'(SETF FOO) ...) form isn't required (the standard just specifies something with the same effect as it). -- Martin Simmons LispWorks Ltd http://www.lispworks.com/
IMO, you will have to see what's done by each implementation, and use implementation specific, perhaps even internal functions to get that information. This would be a good subject for a CDR, to provide a public introspective API. -- __Pascal Bourguignon__ On 08/10/2012, at 15:28, Didier Verna <didier@lrde.epita.fr> wrote:
Hello,
I cannot find a standard way to figure out whether a setf expander has been defined for a symbol FOO (via either DEFSETF or DEFINE-SETF-EXPANDER).
Is there one? Otherwise, I would also be happy with an SBCL-only solution.
Thank you !
-- Resistance is futile. You will be jazzimilated.
Scientific site: http://www.lrde.epita.fr/~didier Music (Jazz) site: http://www.didierverna.com
_______________________________________________ pro mailing list pro@common-lisp.net http://lists.common-lisp.net/cgi-bin/mailman/listinfo/pro
On Oct 9, 2012, at 07:52 , Pascal J. Bourguignon wrote:
IMO, you will have to see what's done by each implementation, and use implementation specific, perhaps even internal functions to get that information.
This would be a good subject for a CDR, to provide a public introspective API.
I second that. A "side" CDR would be to specify other "function specifiers" beside (SETF FOO). Cheers -- MA
-- __Pascal Bourguignon__
On 08/10/2012, at 15:28, Didier Verna <didier@lrde.epita.fr> wrote:
Hello,
I cannot find a standard way to figure out whether a setf expander has been defined for a symbol FOO (via either DEFSETF or DEFINE-SETF-EXPANDER).
Is there one? Otherwise, I would also be happy with an SBCL-only solution.
Thank you !
-- Resistance is futile. You will be jazzimilated.
Scientific site: http://www.lrde.epita.fr/~didier Music (Jazz) site: http://www.didierverna.com
_______________________________________________ pro mailing list pro@common-lisp.net http://lists.common-lisp.net/cgi-bin/mailman/listinfo/pro
_______________________________________________ pro mailing list pro@common-lisp.net http://lists.common-lisp.net/cgi-bin/mailman/listinfo/pro
-- Marco Antoniotti, Associate Professor tel. +39 - 02 64 48 79 01 DISCo, Università Milano Bicocca U14 2043 http://bimib.disco.unimib.it Viale Sarca 336 I-20126 Milan (MI) ITALY Please note that I am not checking my Spam-box anymore. Please do not forward this email without asking me first.
participants (6)
-
Didier Verna
-
Marco Antoniotti
-
Martin Simmons
-
Pascal Costanza
-
Pascal J. Bourguignon
-
Raymond Wiker