From debbugs-submit-bounces@debbugs.gnu.org Wed Jan 22 05:07:07 2014 Received: (at submit) by debbugs.gnu.org; 22 Jan 2014 10:07:07 +0000 Received: from localhost ([127.0.0.1]:60282 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1W5uiA-0005iV-UU for submit@debbugs.gnu.org; Wed, 22 Jan 2014 05:07:07 -0500 Received: from eggs.gnu.org ([208.118.235.92]:56880) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1W5ui9-0005iN-4Z for submit@debbugs.gnu.org; Wed, 22 Jan 2014 05:07:05 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1W5ui0-0008RL-AI for submit@debbugs.gnu.org; Wed, 22 Jan 2014 05:07:04 -0500 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM, T_DKIM_INVALID autolearn=disabled version=3.3.2 Received: from lists.gnu.org ([2001:4830:134:3::11]:46586) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W5ui0-0008RH-6k for submit@debbugs.gnu.org; Wed, 22 Jan 2014 05:06:56 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58588) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W5uhr-00024g-Hk for bug-gnu-emacs@gnu.org; Wed, 22 Jan 2014 05:06:56 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1W5uhj-0008Pu-6E for bug-gnu-emacs@gnu.org; Wed, 22 Jan 2014 05:06:47 -0500 Received: from mail-ee0-x22a.google.com ([2a00:1450:4013:c00::22a]:55360) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W5uhi-0008Ph-Ut for bug-gnu-emacs@gnu.org; Wed, 22 Jan 2014 05:06:39 -0500 Received: by mail-ee0-f42.google.com with SMTP id e49so4761640eek.29 for ; Wed, 22 Jan 2014 02:06:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:subject:date:message-id:mime-version:content-type; bh=pU8oHbULLd6tESxPCO4w8CsXRBTHjBlmPW0x8tkASEY=; b=a8o1Vp7XeDbiA68qlCF+bLNem717LZRtuwJnQX6CSnnXxK67s8C6xiuCtPlYAPpcAw Cp0tL9VzeE/KNeKm4PLFe/almKzV7D8Y8oqx4B32AofJcvRI2+ZB9ZKmaHL3VEd0Tdmj uxxUm6MtdLJP+iMd8IhIrwVXxzYNPMVWIj2NuuEC4Kd72fFoqn47ICgCpS+cDP1naBt8 hF4nesugmqZC/ry998P0E9Wv/shWN6B9y3zsVV/SzStqMYSxPjBiod2/J1xIP6SBjiba 4uewjRq8WjV+nUAVAZYHHRm4MxbEQEzbZ73n69YtH08v7Tki04KUKJjeWS947DXRKbZO m+eA== X-Received: by 10.14.32.132 with SMTP id o4mr670954eea.14.1390385197997; Wed, 22 Jan 2014 02:06:37 -0800 (PST) Received: from ix ([212.46.176.45]) by mx.google.com with ESMTPSA id l4sm25209446een.13.2014.01.22.02.06.36 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Wed, 22 Jan 2014 02:06:37 -0800 (PST) Received: from helmut by ix with local (Exim 4.80) (envelope-from ) id 1W5uhe-00011R-1M for bug-gnu-emacs@gnu.org; Wed, 22 Jan 2014 11:06:34 +0100 From: Helmut Eller To: bug-gnu-emacs@gnu.org Subject: 24.3.50; cl-defstruct with :predicate option Date: Wed, 22 Jan 2014 11:06:34 +0100 Message-ID: MIME-Version: 1.0 Content-Type: text/plain X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2001:4830:134:3::11 X-Spam-Score: -4.0 (----) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -4.0 (----) Compiling this code: (require 'cl-lib) (cl-defstruct (foo (:predicate foop))) (defun bar (x) (cl-check-type x foo)) with with: emacs -Q -batch -f batch-byte-compile foo.el produces this warning: foo.el:8:1:Warning: the function `foo-p' is not known to be defined. and since foo-p is not defined will also lead errors at run-time when bar is called. Adding eval-and-compile to the structure definition avoids the problem but it's a bug that the compiler emits a call to foo-p at all. In GNU Emacs 24.3.50.2 (i686-pc-linux-gnu, GTK+ Version 2.24.10) of 2014-01-20 on ix From debbugs-submit-bounces@debbugs.gnu.org Wed Jan 22 08:47:18 2014 Received: (at 16520) by debbugs.gnu.org; 22 Jan 2014 13:47:18 +0000 Received: from localhost ([127.0.0.1]:60374 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1W5y9G-0004ED-JU for submit@debbugs.gnu.org; Wed, 22 Jan 2014 08:47:18 -0500 Received: from ironport2-out.teksavvy.com ([206.248.154.181]:54363) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1W5y9E-0004E3-RO for 16520@debbugs.gnu.org; Wed, 22 Jan 2014 08:47:17 -0500 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: Av8EABK/CFG4rxHA/2dsb2JhbABEuzWDWRdzgh4BAQQBViMFCws0EhQYDSSIHgbBLZEKA4hhnBmBXoMV X-IPAS-Result: Av8EABK/CFG4rxHA/2dsb2JhbABEuzWDWRdzgh4BAQQBViMFCws0EhQYDSSIHgbBLZEKA4hhnBmBXoMV X-IronPort-AV: E=Sophos;i="4.84,565,1355115600"; d="scan'208";a="45584927" Received: from 184-175-17-192.dsl.teksavvy.com (HELO pastel.home) ([184.175.17.192]) by ironport2-out.teksavvy.com with ESMTP/TLS/ADH-AES256-SHA; 22 Jan 2014 08:47:16 -0500 Received: by pastel.home (Postfix, from userid 20848) id 1314860323; Wed, 22 Jan 2014 08:47:16 -0500 (EST) From: Stefan Monnier To: Helmut Eller Subject: Re: bug#16520: 24.3.50; cl-defstruct with :predicate option Message-ID: References: Date: Wed, 22 Jan 2014 08:47:16 -0500 In-Reply-To: (Helmut Eller's message of "Wed, 22 Jan 2014 11:06:34 +0100") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: 0.3 (/) X-Debbugs-Envelope-To: 16520 Cc: 16520@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 0.3 (/) > Compiling this code: > (require 'cl-lib) > (cl-defstruct (foo (:predicate foop))) > (defun bar (x) (cl-check-type x foo)) > with with: emacs -Q -batch -f batch-byte-compile foo.el > produces this warning: > foo.el:8:1:Warning: the function `foo-p' is not known to be defined. Hmm... indeed, that's bad. Stefan From debbugs-submit-bounces@debbugs.gnu.org Thu Jan 23 10:02:07 2014 Received: (at 16520-done) by debbugs.gnu.org; 23 Jan 2014 15:02:07 +0000 Received: from localhost ([127.0.0.1]:33614 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1W6LnC-0000g9-ID for submit@debbugs.gnu.org; Thu, 23 Jan 2014 10:02:06 -0500 Received: from ironport2-out.teksavvy.com ([206.248.154.181]:56628) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1W6Ln9-0000fv-7d for 16520-done@debbugs.gnu.org; Thu, 23 Jan 2014 10:02:03 -0500 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: Av8EABK/CFG4rxHA/2dsb2JhbABEuzWDWRdzgh8BBVYjEAs0EhQYDSSIJMEtkQoDiGGcGYFegxU X-IPAS-Result: Av8EABK/CFG4rxHA/2dsb2JhbABEuzWDWRdzgh8BBVYjEAs0EhQYDSSIJMEtkQoDiGGcGYFegxU X-IronPort-AV: E=Sophos;i="4.84,565,1355115600"; d="scan'208";a="45897882" Received: from 184-175-17-192.dsl.teksavvy.com (HELO pastel.home) ([184.175.17.192]) by ironport2-out.teksavvy.com with ESMTP/TLS/ADH-AES256-SHA; 23 Jan 2014 10:02:02 -0500 Received: by pastel.home (Postfix, from userid 20848) id 16C6A600BF; Thu, 23 Jan 2014 10:02:02 -0500 (EST) From: Stefan Monnier To: Helmut Eller Subject: Re: bug#16520: 24.3.50; cl-defstruct with :predicate option Message-ID: References: Date: Thu, 23 Jan 2014 10:02:02 -0500 In-Reply-To: (Helmut Eller's message of "Wed, 22 Jan 2014 11:06:34 +0100") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: 0.3 (/) X-Debbugs-Envelope-To: 16520-done Cc: 16520-done@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 0.3 (/) Version: 24.4 > (cl-defstruct (foo (:predicate foop))) > (defun bar (x) (cl-check-type x foo)) [...] > foo.el:8:1:Warning: the function `foo-p' is not known to be defined. Thanks, should be fixed now (more or less: it's an ugly hack). Stefan From debbugs-submit-bounces@debbugs.gnu.org Wed Jan 29 05:01:26 2014 Received: (at submit) by debbugs.gnu.org; 29 Jan 2014 10:01:27 +0000 Received: from localhost ([127.0.0.1]:39816 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1W8RxW-0000En-IA for submit@debbugs.gnu.org; Wed, 29 Jan 2014 05:01:26 -0500 Received: from eggs.gnu.org ([208.118.235.92]:60719) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1W8RxT-0000Ee-QY for submit@debbugs.gnu.org; Wed, 29 Jan 2014 05:01:24 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1W8RxK-0002p1-4j for submit@debbugs.gnu.org; Wed, 29 Jan 2014 05:01:23 -0500 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: * X-Spam-Status: No, score=1.0 required=5.0 tests=BAYES_00,FREEMAIL_FROM, FSL_HELO_BARE_IP_2,RCVD_NUMERIC_HELO autolearn=disabled version=3.3.2 Received: from lists.gnu.org ([2001:4830:134:3::11]:42637) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W8RxK-0002ox-2Q for submit@debbugs.gnu.org; Wed, 29 Jan 2014 05:01:14 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34180) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W8RxC-0004rb-NM for bug-gnu-emacs@gnu.org; Wed, 29 Jan 2014 05:01:14 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1W8Rx1-0002nT-B6 for bug-gnu-emacs@gnu.org; Wed, 29 Jan 2014 05:01:06 -0500 Received: from plane.gmane.org ([80.91.229.3]:37591) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W8Rx1-0002nO-5G for bug-gnu-emacs@gnu.org; Wed, 29 Jan 2014 05:00:55 -0500 Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1W8Rww-0003U5-HA for bug-gnu-emacs@gnu.org; Wed, 29 Jan 2014 11:00:50 +0100 Received: from 212.46.176.45 ([212.46.176.45]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Wed, 29 Jan 2014 11:00:50 +0100 Received: from eller.helmut by 212.46.176.45 with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Wed, 29 Jan 2014 11:00:50 +0100 X-Injected-Via-Gmane: http://gmane.org/ To: bug-gnu-emacs@gnu.org From: Helmut Eller Subject: Re: bug#16520: 24.3.50; cl-defstruct with :predicate option Date: Wed, 29 Jan 2014 11:00:40 +0100 Lines: 22 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain X-Complaints-To: usenet@ger.gmane.org X-Gmane-NNTP-Posting-Host: 212.46.176.45 User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux) Cancel-Lock: sha1:KgsWAXleEL9JLuzKBvrhnAzivgc= X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2001:4830:134:3::11 X-Spam-Score: -1.4 (-) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.2 (---) On Thu, Jan 23 2014, Stefan Monnier wrote: > Version: 24.4 > >> (cl-defstruct (foo (:predicate foop))) >> (defun bar (x) (cl-check-type x foo)) > [...] >> foo.el:8:1:Warning: the function `foo-p' is not known to be defined. > > Thanks, should be fixed now (more or less: it's an ugly hack). The fix doesn't work for this example: (require 'cl-lib) (cl-defstruct (foo (:predicate foo?))) (defun bar (x) (cl-check-type x foo)) neither for (cl-defstruct (foo (:predicate nil))) Helmut From debbugs-submit-bounces@debbugs.gnu.org Wed Jan 29 08:59:55 2014 Received: (at 16520) by debbugs.gnu.org; 29 Jan 2014 13:59:55 +0000 Received: from localhost ([127.0.0.1]:40002 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1W8VgJ-0007NN-9O for submit@debbugs.gnu.org; Wed, 29 Jan 2014 08:59:55 -0500 Received: from ironport2-out.teksavvy.com ([206.248.154.181]:43199) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1W8VgH-0007NG-Co for 16520@debbugs.gnu.org; Wed, 29 Jan 2014 08:59:53 -0500 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: Av8EABK/CFFFpZg5/2dsb2JhbABEuzWDWRdzgh4BAQQBViMFCws0EhQYDSSIHgbBLZEKA4hhnBmBXoMV X-IPAS-Result: Av8EABK/CFFFpZg5/2dsb2JhbABEuzWDWRdzgh4BAQQBViMFCws0EhQYDSSIHgbBLZEKA4hhnBmBXoMV X-IronPort-AV: E=Sophos;i="4.84,565,1355115600"; d="scan'208";a="46335005" Received: from 69-165-152-57.dsl.teksavvy.com (HELO pastel.home) ([69.165.152.57]) by ironport2-out.teksavvy.com with ESMTP/TLS/ADH-AES256-SHA; 29 Jan 2014 08:59:52 -0500 Received: by pastel.home (Postfix, from userid 20848) id 7ED556032D; Wed, 29 Jan 2014 08:59:52 -0500 (EST) From: Stefan Monnier To: Helmut Eller Subject: Re: bug#16520: 24.3.50; cl-defstruct with :predicate option Message-ID: References: Date: Wed, 29 Jan 2014 08:59:52 -0500 In-Reply-To: (Helmut Eller's message of "Wed, 29 Jan 2014 11:00:40 +0100") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: 0.3 (/) X-Debbugs-Envelope-To: 16520 Cc: 16520@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 0.3 (/) > The fix doesn't work for this example: > (require 'cl-lib) > (cl-defstruct (foo (:predicate foo?))) > (defun bar (x) (cl-check-type x foo)) Indeed. But it should work for: (require 'cl-lib) (cl-defstruct (foo (:predicate foo?))) (defun bar (x) (cl-check-type x foo?)) > neither for > (cl-defstruct (foo (:predicate nil))) Not sure if it should work in that case, Stefan From debbugs-submit-bounces@debbugs.gnu.org Wed Jan 29 12:48:02 2014 Received: (at submit) by debbugs.gnu.org; 29 Jan 2014 17:48:02 +0000 Received: from localhost ([127.0.0.1]:40509 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1W8ZF4-0004z8-5G for submit@debbugs.gnu.org; Wed, 29 Jan 2014 12:48:02 -0500 Received: from eggs.gnu.org ([208.118.235.92]:55629) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1W8ZEx-0004yl-87 for submit@debbugs.gnu.org; Wed, 29 Jan 2014 12:47:59 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1W8ZEn-0000WM-GE for submit@debbugs.gnu.org; Wed, 29 Jan 2014 12:47:54 -0500 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: * X-Spam-Status: No, score=1.0 required=5.0 tests=BAYES_00,FREEMAIL_FROM, FSL_HELO_BARE_IP_2,RCVD_NUMERIC_HELO autolearn=disabled version=3.3.2 Received: from lists.gnu.org ([208.118.235.17]:60448) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W8ZEn-0000WA-Cd for submit@debbugs.gnu.org; Wed, 29 Jan 2014 12:47:45 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57261) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W8ZEf-0003Ky-Pp for bug-gnu-emacs@gnu.org; Wed, 29 Jan 2014 12:47:45 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1W8ZEY-0000In-H0 for bug-gnu-emacs@gnu.org; Wed, 29 Jan 2014 12:47:37 -0500 Received: from plane.gmane.org ([80.91.229.3]:54819) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1W8ZEY-0000I3-B6 for bug-gnu-emacs@gnu.org; Wed, 29 Jan 2014 12:47:30 -0500 Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1W8ZEJ-0002mJ-MN for bug-gnu-emacs@gnu.org; Wed, 29 Jan 2014 18:47:15 +0100 Received: from 212.46.176.45 ([212.46.176.45]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Wed, 29 Jan 2014 18:47:15 +0100 Received: from eller.helmut by 212.46.176.45 with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Wed, 29 Jan 2014 18:47:15 +0100 X-Injected-Via-Gmane: http://gmane.org/ To: bug-gnu-emacs@gnu.org From: Helmut Eller Subject: Re: bug#16520: 24.3.50; cl-defstruct with :predicate option Date: Wed, 29 Jan 2014 18:47:05 +0100 Lines: 26 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain X-Complaints-To: usenet@ger.gmane.org X-Gmane-NNTP-Posting-Host: 212.46.176.45 User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux) Cancel-Lock: sha1:zL1CCMN728XZpsdeIQy+7Tc+3k4= X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 208.118.235.17 X-Spam-Score: -1.4 (-) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.2 (---) On Wed, Jan 29 2014, Stefan Monnier wrote: >> The fix doesn't work for this example: > >> (require 'cl-lib) >> (cl-defstruct (foo (:predicate foo?))) >> (defun bar (x) (cl-check-type x foo)) > > Indeed. But it should work for: > > (require 'cl-lib) > (cl-defstruct (foo (:predicate foo?))) > (defun bar (x) (cl-check-type x foo?)) Which is arguably a bug. If the goal is to imitate Common Lisp semantics then the type name is foo not foo?. If I wanted to call a predicate I would have written (check-type x (satisfies foo?)). >> neither for >> (cl-defstruct (foo (:predicate nil))) > > Not sure if it should work in that case, It does work in Common Lisp. Helmut From debbugs-submit-bounces@debbugs.gnu.org Wed Jan 29 22:58:49 2014 Received: (at 16520) by debbugs.gnu.org; 30 Jan 2014 03:58:49 +0000 Received: from localhost ([127.0.0.1]:40789 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1W8im9-0002nf-7g for submit@debbugs.gnu.org; Wed, 29 Jan 2014 22:58:49 -0500 Received: from ironport2-out.teksavvy.com ([206.248.154.181]:53732) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1W8im6-0002nU-5L for 16520@debbugs.gnu.org; Wed, 29 Jan 2014 22:58:46 -0500 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: Av8EABK/CFFFpaEq/2dsb2JhbABEuzWDWRdzgh4BAQQBViMQCzQSFBgNJIgeBsEtkQoDiGGcGYFegxU X-IPAS-Result: Av8EABK/CFFFpaEq/2dsb2JhbABEuzWDWRdzgh4BAQQBViMQCzQSFBgNJIgeBsEtkQoDiGGcGYFegxU X-IronPort-AV: E=Sophos;i="4.84,565,1355115600"; d="scan'208";a="46398890" Received: from 69-165-161-42.dsl.teksavvy.com (HELO pastel.home) ([69.165.161.42]) by ironport2-out.teksavvy.com with ESMTP/TLS/ADH-AES256-SHA; 29 Jan 2014 22:58:45 -0500 Received: by pastel.home (Postfix, from userid 20848) id EE96D600CA; Wed, 29 Jan 2014 22:58:44 -0500 (EST) From: Stefan Monnier To: Helmut Eller Subject: Re: bug#16520: 24.3.50; cl-defstruct with :predicate option Message-ID: References: Date: Wed, 29 Jan 2014 22:58:44 -0500 In-Reply-To: (Helmut Eller's message of "Wed, 29 Jan 2014 18:47:05 +0100") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: 0.3 (/) X-Debbugs-Envelope-To: 16520 Cc: 16520@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 0.3 (/) >>> neither for >>> (cl-defstruct (foo (:predicate nil))) >> Not sure if it should work in that case, > It does work in Common Lisp. Then.. patch welcome ;-) Stefan From debbugs-submit-bounces@debbugs.gnu.org Thu Jan 30 07:07:30 2014 Received: (at 16520) by debbugs.gnu.org; 30 Jan 2014 12:07:30 +0000 Received: from localhost ([127.0.0.1]:40979 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1W8qP3-0006FG-Jy for submit@debbugs.gnu.org; Thu, 30 Jan 2014 07:07:30 -0500 Received: from mail-ea0-f173.google.com ([209.85.215.173]:52219) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1W8qP1-0006F8-Jr for 16520@debbugs.gnu.org; Thu, 30 Jan 2014 07:07:28 -0500 Received: by mail-ea0-f173.google.com with SMTP id d10so1595423eaj.4 for <16520@debbugs.gnu.org>; Thu, 30 Jan 2014 04:07:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version:content-type; bh=KhnZw+89JUNty3thu7KMPVG1D/8G1TKwdqb3yyCRqxg=; b=Kb0UgbV6jBXWk5PkEqMW1yoHrsUQ7mHtoC+lS0CrAjLXhU5yxspvjRRs9z5lzZEVzP wHU4pqIT6cGNqLbEEJBdv8FgkoP7bmmf8Cps7CFe08O/oo0mjU1YSW1silrV0tct7NSE JCz91nu6Wv3eEFQjQFOFsUzxd2oarTRa7iKcdXM8Q6KbMryvqEqgWuo9RhUI73FN2VYm v0jwZ1oQ+vJdDSoY7Did5hNDfXxMkuxgXeAtRbc6MpPxSHVdLnZFy/eaR3FCiTZZx+4g yt8RtqbWIQUJXUB1jWql6P9JS10g+PPiPmt12uo4WWtunicy7uOzutXJKLYarSS9Lg2/ rhdg== X-Received: by 10.15.107.205 with SMTP id cb53mr89933eeb.107.1391083646712; Thu, 30 Jan 2014 04:07:26 -0800 (PST) Received: from ix ([212.46.176.45]) by mx.google.com with ESMTPSA id 8sm21610535eeq.15.2014.01.30.04.07.23 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Thu, 30 Jan 2014 04:07:24 -0800 (PST) Received: from helmut by ix with local (Exim 4.80) (envelope-from ) id 1W8qOu-0001Vp-0M; Thu, 30 Jan 2014 13:07:20 +0100 From: Helmut Eller To: Stefan Monnier Subject: Re: bug#16520: 24.3.50; cl-defstruct with :predicate option References: Date: Thu, 30 Jan 2014 13:07:19 +0100 In-Reply-To: (Stefan Monnier's message of "Wed, 29 Jan 2014 22:58:44 -0500") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 16520 Cc: 16520@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.7 (/) --=-=-= Content-Type: text/plain On Thu, Jan 30 2014, Stefan Monnier wrote: >>>> neither for >>>> (cl-defstruct (foo (:predicate nil))) >>> Not sure if it should work in that case, >> It does work in Common Lisp. > > Then.. patch welcome ;-) Maybe something like this: --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=defstruct.patch diff --git a/lisp/emacs-lisp/cl-macs.el b/lisp/emacs-lisp/cl-macs.el index 45448ec..d8e62c3 100644 --- a/lisp/emacs-lisp/cl-macs.el +++ b/lisp/emacs-lisp/cl-macs.el @@ -2569,6 +2569,7 @@ non-nil value, that slot cannot be set via `setf'. (push `(cl-eval-when (compile load eval) (put ',name 'cl-struct-slots ',descs) (put ',name 'cl-struct-type ',(list type (eq named t))) + (put ',name 'cl-struct-tag-symbol ',tag-symbol) (put ',name 'cl-struct-include ',include) (put ',name 'cl-struct-print ,print-auto) ,@(mapcar (lambda (x) @@ -2599,6 +2600,26 @@ Of course, we really can't know that for sure, so it's just a heuristic." (or (cdr (assq sym byte-compile-function-environment)) (cdr (assq sym byte-compile-macro-environment)))))) +(defun cl--make-struct-type-test (val type) + (let* ((stype (get type 'cl-struct-type)) + (slots (get type 'cl-struct-slots)) + (tag-symbol (get type 'cl-struct-tag-symbol)) + (pos (cl-loop for i from 0 for s in slots + when (eq (car s) 'cl-tag-slot) return i))) + (or pos (error "Not a named struct: %s" type)) + (cl-ecase (car stype) + (vector `(and (vectorp ,val) + (>= (length ,val) ,(length slots)) + (memq (aref ,val ,pos) ,tag-symbol) + t)) + (list (cond ((zerop pos) + `(and (memq (car-safe ,val) ,tag-symbol) + t)) + (t + `(and (consp ,val) + (memq (nth ,pos ,val) ,tag-symbol) + t))))))) + (defun cl--make-type-test (val type) (if (symbolp type) (cond ((get type 'cl-deftype-handler) @@ -2611,6 +2632,9 @@ Of course, we really can't know that for sure, so it's just a heuristic." ((eq type 'fixnum) `(integerp ,val)) ;; FIXME: Should `character' accept things like ?\C-\M-a ? --Stef ((memq type '(character string-char)) `(characterp ,val)) + ((and (get type 'cl-struct-type) + (assq 'cl-tag-slot (get type 'cl-struct-slots))) + (cl--make-struct-type-test val type)) (t (let* ((name (symbol-name type)) (namep (intern (concat name "p")))) diff --git a/test/automated/cl-lib.el b/test/automated/cl-lib.el index 8b6ed6d..3689c9c 100644 --- a/test/automated/cl-lib.el +++ b/test/automated/cl-lib.el @@ -195,4 +195,17 @@ (should (eql (cl-mismatch "Aa" "aA") 0)) (should (eql (cl-mismatch '(a b c) '(a b d)) 2))) +(cl-defstruct cl-lib-test-struct-1) +(cl-defstruct (cl-lib-test-struct-2 (:predicate cl-lib-test-struct-2?))) +(cl-defstruct (cl-lib-test-struct-3 (:predicate nil))) +(cl-defstruct (cl-lib-test-struct-4 (:predicate nil) + (:include cl-lib-test-struct-3))) + +(ert-deftest cl-lib-test-typep () + (should (cl-typep (make-cl-lib-test-struct-1) 'cl-lib-test-struct-1)) + (should (not (cl-typep (make-cl-lib-test-struct-2) 'cl-lib-test-struct-1))) + (should (cl-typep (make-cl-lib-test-struct-2) 'cl-lib-test-struct-2)) + (should (cl-typep (make-cl-lib-test-struct-3) 'cl-lib-test-struct-3)) + (should (cl-typep (make-cl-lib-test-struct-4) 'cl-lib-test-struct-3))) + ;;; cl-lib.el ends here --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Thu Jan 30 09:43:53 2014 Received: (at 16520) by debbugs.gnu.org; 30 Jan 2014 14:43:53 +0000 Received: from localhost ([127.0.0.1]:41236 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1W8sqO-0002n3-Tr for submit@debbugs.gnu.org; Thu, 30 Jan 2014 09:43:53 -0500 Received: from ironport2-out.teksavvy.com ([206.248.154.181]:27837) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1W8sqN-0002mv-G7 for 16520@debbugs.gnu.org; Thu, 30 Jan 2014 09:43:51 -0500 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: Av8EABK/CFHO+J67/2dsb2JhbABEuzWDWRdzgh4BAQQBViMFCws0EhQYDSSIHgbBLZEKA4hhnBmBXoMV X-IPAS-Result: Av8EABK/CFHO+J67/2dsb2JhbABEuzWDWRdzgh4BAQQBViMFCws0EhQYDSSIHgbBLZEKA4hhnBmBXoMV X-IronPort-AV: E=Sophos;i="4.84,565,1355115600"; d="scan'208";a="46416425" Received: from 206-248-158-187.dsl.teksavvy.com (HELO pastel.home) ([206.248.158.187]) by ironport2-out.teksavvy.com with ESMTP/TLS/ADH-AES256-SHA; 30 Jan 2014 09:43:50 -0500 Received: by pastel.home (Postfix, from userid 20848) id A9BCF60171; Thu, 30 Jan 2014 09:43:50 -0500 (EST) From: Stefan Monnier To: Helmut Eller Subject: Re: bug#16520: 24.3.50; cl-defstruct with :predicate option Message-ID: References: Date: Thu, 30 Jan 2014 09:43:50 -0500 In-Reply-To: (Helmut Eller's message of "Thu, 30 Jan 2014 13:07:19 +0100") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: 0.3 (/) X-Debbugs-Envelope-To: 16520 Cc: 16520@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 0.3 (/) > Maybe something like this: Thanks, looks reasonable. Could you try and share the cl--make-struct-type-test code with the part that defines foo-p to avoid the duplication? Stefan From debbugs-submit-bounces@debbugs.gnu.org Thu Jan 30 17:33:14 2014 Received: (at 16520) by debbugs.gnu.org; 30 Jan 2014 22:33:14 +0000 Received: from localhost ([127.0.0.1]:41824 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1W90Ab-0000rC-Ff for submit@debbugs.gnu.org; Thu, 30 Jan 2014 17:33:14 -0500 Received: from mail-ea0-f178.google.com ([209.85.215.178]:47242) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1W90AY-0000r3-E0 for 16520@debbugs.gnu.org; Thu, 30 Jan 2014 17:33:11 -0500 Received: by mail-ea0-f178.google.com with SMTP id a15so1941342eae.23 for <16520@debbugs.gnu.org>; Thu, 30 Jan 2014 14:33:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version:content-type; bh=IhWa3GuGAqbtQ4PDUt3rEUTwjT3GUeNjpKNOAvPJ07c=; b=KdqIOxLTBqEkjh9LIdaIvEh11nHVz6kbc0SPxUgh/koXS7GSNy9Cwz89L/k2/ww1gp umBplV2S25FtLWIvR7mXySNankua4wM/foN9iDPudMp8PRbflDPJmdmZRnTQboiGgzbi gPd9o5L1HcutZSQpyn9pew6bOW4yScqNQUwOC9UgMc1w6cRYVFq3/2c6bp08g6MeTne4 hHFHy/xF6iPZZq4QjL5JRlG2Qwzwd6zly0ba5qAX01F/FXZDvnVgUcbPGp5JgOqGd2KV l3RaeOrzI7uqoNo+zjMX9ZjhvaUe252fVpVeDKGxPp/kCrg5vmEuGf91g3AFYDkuSVEX kp5Q== X-Received: by 10.14.210.130 with SMTP id u2mr253874eeo.108.1391121189605; Thu, 30 Jan 2014 14:33:09 -0800 (PST) Received: from ix ([212.46.176.45]) by mx.google.com with ESMTPSA id 46sm28190973ees.4.2014.01.30.14.33.07 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Thu, 30 Jan 2014 14:33:08 -0800 (PST) Received: from helmut by ix with local (Exim 4.80) (envelope-from ) id 1W90AV-000240-Rm; Thu, 30 Jan 2014 23:33:08 +0100 From: Helmut Eller To: Stefan Monnier Subject: Re: bug#16520: 24.3.50; cl-defstruct with :predicate option References: Date: Thu, 30 Jan 2014 23:33:07 +0100 In-Reply-To: (Stefan Monnier's message of "Thu, 30 Jan 2014 09:43:50 -0500") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 16520 Cc: 16520@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.7 (/) --=-=-= Content-Type: text/plain On Thu, Jan 30 2014, Stefan Monnier wrote: >> Maybe something like this: > > Thanks, looks reasonable. Could you try and share the > cl--make-struct-type-test code with the part that defines foo-p to avoid > the duplication? I tried but it doesn't look much better: --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=defstruct.patch diff --git a/lisp/emacs-lisp/cl-macs.el b/lisp/emacs-lisp/cl-macs.el index 45448ec..12f8ab1 100644 --- a/lisp/emacs-lisp/cl-macs.el +++ b/lisp/emacs-lisp/cl-macs.el @@ -2319,6 +2319,40 @@ Like `cl-callf', but PLACE is the second argument of FUNC, not the first. ;;; Structures. +(defun cl--make-struct-type-test (val type slots tag-symbol) + (let ((pos (cl-loop for i from 0 for (s) in slots + when (eq s 'cl-tag-slot) return i))) + (cl-ecase type + (vector + `(and (vectorp ,val) + (>= (length ,val) ,(length slots)) + (memq (aref ,val ,pos) ,tag-symbol) + t)) + (list + (cond ((zerop pos) + `(and (memq (car-safe ,val) ,tag-symbol) + t)) + (t + `(and (consp ,val) + (memq (nth ,pos ,val) ,tag-symbol) + t))))))) + +(defun cl--make-struct-check-form (pred-form safety) + (cond ((= safety 0) nil) + (t (let* ((form (cond ((and (eq (car pred-form) 'and) + (eq (car (last pred-form)) 't)) + (butlast pred-form)) + (t pred-form))) + (form (cond ((and (eq (car form) 'and) + (= (length form) 2)) + (nth 1 form)) + (t form)))) + (cond ((and (= safety 1) + (eq (car form) 'and) + (eq (car (nth 1 form)) 'vectorp)) + (nth 3 form)) + (t form)))))) + ;;;###autoload (defmacro cl-defstruct (struct &rest descs) "Define a struct type. @@ -2461,21 +2495,10 @@ non-nil value, that slot cannot be set via `setf'. (or named (setq descs (delq (assq 'cl-tag-slot descs) descs))) (push `(defvar ,tag-symbol) forms) (setq pred-form (and named - (let ((pos (- (length descs) - (length (memq (assq 'cl-tag-slot descs) - descs))))) - (if (eq type 'vector) - `(and (vectorp cl-x) - (>= (length cl-x) ,(length descs)) - (memq (aref cl-x ,pos) ,tag-symbol)) - (if (= pos 0) - `(memq (car-safe cl-x) ,tag-symbol) - `(and (consp cl-x) - (memq (nth ,pos cl-x) ,tag-symbol)))))) - pred-check (and pred-form (> safety 0) - (if (and (eq (cl-caadr pred-form) 'vectorp) - (= safety 1)) - (cons 'and (cl-cdddr pred-form)) pred-form))) + (cl--make-struct-type-test 'cl-x type descs + tag-symbol)) + pred-check (and pred-form + (cl--make-struct-check-form pred-form safety))) (let ((pos 0) (descp descs)) (while descp (let* ((desc (pop descp)) @@ -2530,10 +2553,7 @@ non-nil value, that slot cannot be set via `setf'. (setq slots (nreverse slots) defaults (nreverse defaults)) (and predicate pred-form - (progn (push `(cl-defsubst ,predicate (cl-x) - ,(if (eq (car pred-form) 'and) - (append pred-form '(t)) - `(and ,pred-form t))) forms) + (progn (push `(cl-defsubst ,predicate (cl-x) ,pred-form) forms) (push (cons predicate 'error-free) side-eff))) (and copier (progn (push `(defun ,copier (x) (copy-sequence x)) forms) @@ -2569,6 +2589,7 @@ non-nil value, that slot cannot be set via `setf'. (push `(cl-eval-when (compile load eval) (put ',name 'cl-struct-slots ',descs) (put ',name 'cl-struct-type ',(list type (eq named t))) + (put ',name 'cl-struct-tag-symbol ',tag-symbol) (put ',name 'cl-struct-include ',include) (put ',name 'cl-struct-print ,print-auto) ,@(mapcar (lambda (x) @@ -2611,6 +2632,12 @@ Of course, we really can't know that for sure, so it's just a heuristic." ((eq type 'fixnum) `(integerp ,val)) ;; FIXME: Should `character' accept things like ?\C-\M-a ? --Stef ((memq type '(character string-char)) `(characterp ,val)) + ((and (get type 'cl-struct-type) + (assq 'cl-tag-slot (get type 'cl-struct-slots))) + (cl--make-struct-type-test val + (car (get type 'cl-struct-type)) + (get type 'cl-struct-slots) + (get type 'cl-struct-tag-symbol))) (t (let* ((name (symbol-name type)) (namep (intern (concat name "p")))) diff --git a/test/automated/cl-lib.el b/test/automated/cl-lib.el index 8b6ed6d..3689c9c 100644 --- a/test/automated/cl-lib.el +++ b/test/automated/cl-lib.el @@ -195,4 +195,17 @@ (should (eql (cl-mismatch "Aa" "aA") 0)) (should (eql (cl-mismatch '(a b c) '(a b d)) 2))) +(cl-defstruct cl-lib-test-struct-1) +(cl-defstruct (cl-lib-test-struct-2 (:predicate cl-lib-test-struct-2?))) +(cl-defstruct (cl-lib-test-struct-3 (:predicate nil))) +(cl-defstruct (cl-lib-test-struct-4 (:predicate nil) + (:include cl-lib-test-struct-3))) + +(ert-deftest cl-lib-test-typep () + (should (cl-typep (make-cl-lib-test-struct-1) 'cl-lib-test-struct-1)) + (should (not (cl-typep (make-cl-lib-test-struct-2) 'cl-lib-test-struct-1))) + (should (cl-typep (make-cl-lib-test-struct-2) 'cl-lib-test-struct-2)) + (should (cl-typep (make-cl-lib-test-struct-3) 'cl-lib-test-struct-3)) + (should (cl-typep (make-cl-lib-test-struct-4) 'cl-lib-test-struct-3))) + ;;; cl-lib.el ends here --=-=-=-- From unknown Sun Jun 22 03:56:14 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Fri, 28 Feb 2014 12:24:05 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator