From: Andreas Politz <politza@hochschule-trier.de>
To: emacs-devel@gnu.org
Subject: defclass's :initarg weirdness
Date: Sat, 04 Mar 2017 06:10:32 +0100 [thread overview]
Message-ID: <87innpd3uf.fsf@luca> (raw)
This is just a minor thing, but the macro defclass evaluates the
:initform form of it's attributes depending on the Lisp-form it has,
which is surprising.
#+BEGIN_SRC emacs-lisp
;; -*- lexical-binding : t -*-
(defconst string "Hey, ho, let's go !")
(defclass class1 nil
((attr :type string :initform string)))
;; => (invalid-slot-type attr string string)
(defclass class2 nil
((attr :type string :initform (let nil string))))
;; => class2
(let ((string "foo"))
(defclass class3 nil
((attr :type string :initform (let nil string)))))
(oref (make-instance 'class3) attr)
;; => "Hey, ho, let's go !"
#+END_SRC
The *Help* buffer does not mention this "weirdness", while the info
file is not helpful either.
,----[ (info "(eieio) Slot Options") ]
| The value passed to initform used to be automatically quoted.
| Thus,
| :initform (1 2 3)
| will use the list as a value. This is incompatible with CLOS
| (which would signal an error since 1 is not a valid function) and
| will likely change in the future, so better quote your initforms if
| they’re just values.
`----
Can this be changed to a lexically scoped evaluation at object creation
time ? If not, it should at least be clearly stated in defclass's
documentation what the evaluation rules are.
-ap
reply other threads:[~2017-03-04 5:10 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87innpd3uf.fsf@luca \
--to=politza@hochschule-trier.de \
--cc=emacs-devel@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.