From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Andreas Politz Newsgroups: gmane.emacs.devel Subject: defclass's :initarg weirdness Date: Sat, 04 Mar 2017 06:10:32 +0100 Message-ID: <87innpd3uf.fsf@luca> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Trace: blaine.gmane.org 1488604287 31622 195.159.176.226 (4 Mar 2017 05:11:27 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sat, 4 Mar 2017 05:11:27 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.0.50 (gnu/linux) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sat Mar 04 06:11:23 2017 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ck1yR-0007aA-MN for ged-emacs-devel@m.gmane.org; Sat, 04 Mar 2017 06:11:19 +0100 Original-Received: from localhost ([::1]:33968 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ck1yX-0007TO-PU for ged-emacs-devel@m.gmane.org; Sat, 04 Mar 2017 00:11:25 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:46707) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ck1y0-0007TI-1a for emacs-devel@gnu.org; Sat, 04 Mar 2017 00:10:53 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ck1xu-0007qV-UV for emacs-devel@gnu.org; Sat, 04 Mar 2017 00:10:51 -0500 Original-Received: from gateway-a.fh-trier.de ([143.93.54.181]:44897) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1ck1xu-0007on-KA for emacs-devel@gnu.org; Sat, 04 Mar 2017 00:10:46 -0500 X-Virus-Scanned: by Amavisd-new + McAfee uvscan + ClamAV [Rechenzentrum Hochschule Trier (RZ/HT)] Original-Received: from localhost (ip5f5bdeea.dynamic.kabel-deutschland.de [95.91.222.234]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) (Authenticated sender: politza) by gateway-a.fh-trier.de (Postfix) with ESMTPSA id 0FAB8179B066 for ; Sat, 4 Mar 2017 06:10:33 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha1; c=simple/simple; d=hochschule-trier.de; s=default; t=1488604233; bh=NoiL2TD0SDWAsLzPexM88JLkiMs=; h=From:To:Subject:Date:Message-ID:MIME-Version:Content-Type: Content-Transfer-Encoding; b=I3N9GozZcqxFzIkcyDqvQB2MTjahRsv0MfFkCCRp5yH7wjNI/5v0OZFd2NI06M1No j6HxHTkMdhVllr6Pv29/lYo19bzJLP7MbBfb+Uifb1OAsy9Th7lqDP+dgfcNm8Oyf0 5nlbnWYpi5lRraGxWl8Qj9dN95qwdTJkgFuibhB0= X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x [fuzzy] X-Received-From: 143.93.54.181 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:212748 Archived-At: 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))) ;; =3D> (invalid-slot-type attr string string) (defclass class2 nil ((attr :type string :initform (let nil string)))) ;; =3D> class2 (let ((string "foo")) (defclass class3 nil ((attr :type string :initform (let nil string))))) (oref (make-instance 'class3) attr) ;; =3D> "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=E2=80=99re 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