0

common lisp has a with-accessors macro which is pretty useful but it is still prone to lots of code duplication.

Is there a convenient let/binding macro that makes all accessors from a defclass available as variables without having to name them all in advance? It would require a magical lookup of the class accessor definition at macro expansion time and I'm not sure if that's possible.

  • Do you mean Emacs-Lisp defclass, which is in eieio? Or do you mean Common-Lisp defclass (which I don't think Emacs Lisp has an emulation of - no cl-defclass)? – Drew May 25 '16 at 22:49
  • Actually EIEIO's defclass is pretty close to Common-Lisp's. – Stefan May 26 '16 at 1:21
  • 1
    @fommil: as you guessed, while it could arguably be possible in some cases, it's basically impossible in general to do that at macroexpansion time. OTOH we could provide something like that if you provide the name of the class/struct. – Stefan May 26 '16 at 1:22
  • If the macro just took an extra parameter, the name of the class, I'd be delighted! Would need the support the accessors of parent classes too. This could allow us to basically rewrite ensime in much less code. – fommil May 26 '16 at 6:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.