From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Drew Adams Newsgroups: gmane.emacs.bugs Subject: bug#47427: [External] : Re: bug#47427: 26.3; 1. Please define a built-in predicate `plistp', 2. wrong type wrong-type-argument error Date: Sun, 28 Mar 2021 16:39:29 +0000 Message-ID: References: <878s67788i.fsf@gnus.org> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="28983"; mail-complaints-to="usenet@ciao.gmane.io" Cc: "47427@debbugs.gnu.org" <47427@debbugs.gnu.org> To: Lars Ingebrigtsen Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sun Mar 28 18:40:38 2021 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lQYSr-0007SQ-RO for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 28 Mar 2021 18:40:38 +0200 Original-Received: from localhost ([::1]:39562 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lQYSq-0004S2-IZ for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 28 Mar 2021 12:40:36 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:34246) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lQYSI-0004Rt-CP for bug-gnu-emacs@gnu.org; Sun, 28 Mar 2021 12:40:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:35365) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lQYSI-00051B-5e for bug-gnu-emacs@gnu.org; Sun, 28 Mar 2021 12:40:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1lQYSI-0001EC-0d for bug-gnu-emacs@gnu.org; Sun, 28 Mar 2021 12:40:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Drew Adams Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 28 Mar 2021 16:40:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 47427 X-GNU-PR-Package: emacs Original-Received: via spool by 47427-submit@debbugs.gnu.org id=B47427.16169495814690 (code B ref 47427); Sun, 28 Mar 2021 16:40:01 +0000 Original-Received: (at 47427) by debbugs.gnu.org; 28 Mar 2021 16:39:41 +0000 Original-Received: from localhost ([127.0.0.1]:46911 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lQYRx-0001Da-EM for submit@debbugs.gnu.org; Sun, 28 Mar 2021 12:39:41 -0400 Original-Received: from aserp2120.oracle.com ([141.146.126.78]:36230) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lQYRw-0001DN-3i for 47427@debbugs.gnu.org; Sun, 28 Mar 2021 12:39:40 -0400 Original-Received: from pps.filterd (aserp2120.oracle.com [127.0.0.1]) by aserp2120.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 12SGZv28148882; Sun, 28 Mar 2021 16:39:32 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : references : in-reply-to : content-type : content-transfer-encoding : mime-version; s=corp-2020-01-29; bh=I5xtez3Aah1tWsS4KrGV+6HErUFv6hQpkx/bKx6wkGk=; b=IJW+zCt7DRGL4zsEr6Ayf5wicOLAGPQcECcoYCp9Sm40eTSbpCE4LU9TumE1Qze/0BBM ReS2a1STTK8LlJE3OcTRBeoPQcU47mSFBajmVVBLRpT8hhss2AXJk3hcNTlxCcF/bDmi Evp6ElSiVktKcKvvnBReix79kqyLrzlFIVCwsI3z0T9XwHyFGJS9ahMdxM1LZtl3lB0W kaRy8MBdoKPx35vLu1OnSHJ06YW+mwZMBjWuw0mNS6vTlqzSFkcf5vetywUd/McpEGuB R5yMlBTZt//Bf3nMJ5V2M5j8czWcbmZMjXId93acYIJtnHMUgn6PpuzrPu4zc7PR9aix Qw== Original-Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by aserp2120.oracle.com with ESMTP id 37hvnm1q9n-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sun, 28 Mar 2021 16:39:32 +0000 Original-Received: from pps.filterd (userp3020.oracle.com [127.0.0.1]) by userp3020.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 12SGaS8B181048; Sun, 28 Mar 2021 16:39:31 GMT Original-Received: from nam12-dm6-obe.outbound.protection.outlook.com (mail-dm6nam12lp2177.outbound.protection.outlook.com [104.47.59.177]) by userp3020.oracle.com with ESMTP id 37jefpu0uu-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sun, 28 Mar 2021 16:39:31 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=WScXY1DSGgQhyPp156k7vheZYpzgd0Quj/TgOSCZCXrSmYydLocM2QR7+GAAdmk83AR2hJV6tuicvJjs1pcz0O2DKoqDJyemRARp8CFcsO+y7w897ik2VKQZszdTJEEyXnIsEoiwCV53VL8Yfswgn7Pf3zMTNSEV0E//XtmHdPh0P08/sSGhgFUNTmNNYZLV9h3bXkxCIXv6Ik4n6WYU2MBXbut3EO6dOIGKvajzJEeHmQVL56BdbxUOO8pl3FNXZ5Jl/MMAvO9sEANARYO3/43k0lIpNAv2o3MrTPsojZs8j8P5q2IyS3GIoqMBv22Z9ifmjEXV4np9J9I1eTnDDg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=I5xtez3Aah1tWsS4KrGV+6HErUFv6hQpkx/bKx6wkGk=; b=EXubOJSpnvGvuWKIpMFmSk3Jg3lE2cQuyu4+RCCGp+tK51fnIiXdSxethkcUUDNOaCBY+WW75BmwHimmlYw6mkIapnVc/VQdVqSkGZAdAeEI3jtN4KPKU7uaMC5eO2fYvj+6PRJb2xHZiyzjC16nn8IILdsg+d/fRhWS30fj3mqTcdgdcuQ7dpnmGuP5aJWnj70BqOL8ffjSuTqzOqzYqnscJNNXY2Dx4AKwYYKlTcbwTDJSMkq+pbosp06b+KH9vs2as9h2E5uQPY5PFQMfzoKGwggZkB1PtfJXsq3BGtMsaxT8YwtxWlbIvqtuyAxWjg0JyDdqfL+sZzjPtcHAQA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.onmicrosoft.com; s=selector2-oracle-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=I5xtez3Aah1tWsS4KrGV+6HErUFv6hQpkx/bKx6wkGk=; b=xwYDO5hW6tHk2uarisxtNd5aID7jTDFDNLsk85YG5BGUjp2qiVKotghqJPXyem419xrDPf2xheXN7Z+wSqUOlLn0TqM+s+MU1wz1NWNTc0EisMyF3ea1DfW2qYp0P1BuAEEJxaPAurLDAbFF0R1a+bPGpwPp4+tgy7xTn9YPsN8= Original-Received: from SA2PR10MB4474.namprd10.prod.outlook.com (2603:10b6:806:11b::15) by SN6PR10MB2669.namprd10.prod.outlook.com (2603:10b6:805:40::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3977.29; Sun, 28 Mar 2021 16:39:29 +0000 Original-Received: from SA2PR10MB4474.namprd10.prod.outlook.com ([fe80::b8d2:db6d:3e4b:d315]) by SA2PR10MB4474.namprd10.prod.outlook.com ([fe80::b8d2:db6d:3e4b:d315%5]) with mapi id 15.20.3977.033; Sun, 28 Mar 2021 16:39:29 +0000 Thread-Topic: [External] : Re: bug#47427: 26.3; 1. Please define a built-in predicate `plistp', 2. wrong type wrong-type-argument error Thread-Index: AdcijyJHrYJvnW6yT0OQXA4sPsn37QBQdLqcAAdGUOA= In-Reply-To: <878s67788i.fsf@gnus.org> Accept-Language: en-US Content-Language: en-US authentication-results: gnus.org; dkim=none (message not signed) header.d=none;gnus.org; dmarc=none action=none header.from=oracle.com; x-originating-ip: [73.170.83.28] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 9982df19-5a37-4921-b4e1-08d8f2080e9f x-ms-traffictypediagnostic: SN6PR10MB2669: x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:10000; x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: erfm+yfEeoXQ5OM2SntLYOuFV+hT1zuPgLHNxbCNqvV0f6FGyEubEke4T+2gGTvDSZBbvroqyjpdHdtwL3nEJ4NoTP+fFoKtZV8s188okVIO740rkoKcPiBbnnk5V37SlTlahlMddturHhDFlAvqiGCcNubWf8SkmvEBVsS17BlizCA1GPjgdhqAKROYIAM+ZKB7BBqtSR8P2StTlJN3TnwvzPR/7bCcs9sQNxGhVhkVe69ylRVrjS1p+5qxbp+Ot2MOlwnTPT1866c4lpBHxkeYIkmgADvNXHV9DppzbhKggBWzFScn4xV5b09lsMKKGbeeRvlKnRFUR/Q5N43QPPpUXwdB1TeQ/Tzh9u/ZjXv/Q1HBjBI8nGtbGiin9MzKSmdqSnxsUGptxHHY27mLX2lY3ZaaCd/Xj0FsDV1uAGkqQUKVbHoAwmu78aZnRl9gwdXGpxbad9lvupVg0JOnpGMRRU5/ehm9eU3TPt9kcqh1YhL+ZFCYgTKbkyLJzrUNqbgkcFma/As5UmzpZLyEM63E1NrHL3u5ycy96jBe03y8LynpT8d2J2PIGHOmF1kOJdp4+a/jSCderMDb/GnDKKLggxe6B9DvWlxaqsWkcPLBVrMoRTrp90Mi7olkKIUEU/iXIzhnHmJCkOPt1qgdTBqBwu0XsCfS0flfdbhMM5GIWMEal0enR4E17q5e+woY x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:SA2PR10MB4474.namprd10.prod.outlook.com; PTR:; CAT:NONE; SFS:(396003)(136003)(366004)(376002)(346002)(39860400002)(33656002)(76116006)(2906002)(71200400001)(6506007)(55016002)(26005)(83380400001)(7696005)(186003)(44832011)(9686003)(8936002)(38100700001)(52536014)(66946007)(5660300002)(86362001)(316002)(478600001)(66446008)(64756008)(66556008)(66476007)(6916009)(4326008)(8676002)(81973001); DIR:OUT; SFP:1101; x-ms-exchange-antispam-messagedata: AUDKy1lX4Fc7nw31H52BUGl4+lfLRb/jLa5v2nHYKVBpk4foZKpvRbRiG3hAYdoVw2XxAiAmSw2Z1Hq6eUVCkdLr5gvXpZF0xXZc12/it1xy6AKqMjEjkf+k6vhK07IJjAzqy/suQviugBPVdoFpHkI2N8yYiNEBi8oqGr9eIDIryKWqYUQ2qm3yfQhgNCfmjtRIg3gr2cnvU11D00s1lZD301N/2Reybq5PXFstb/OJxIlx5xdovzFP1W/JQOd9o2j2ZSY0ezTjnxPuCLr/xQMFzUBt+rcE9QRwzPt6yWGlEkBo00NHiuSL838ufZscHOnVjJ1YDAMkLaYeU51YVBRa/ZxCBkfNl9BH9EDIpt03L2NAznjYZkiUiUWIEBMlKXRhO5PCwVrsTBAjcDQ00qSzR8l+NWCXwQ2QEpyEZKn7d6wyvQzHhuVQHx+y7MkcNPQ+6ohVTxYC85LBldqVwLsKx0TrM41aRw5YmMxeiizkK1Av8M3d5/zs7vAJMejfC71cAPdSny1HHo4f0OTjFMKa0mF35Fh0rdfWWRg+pYIOIyxnEbLBCMTK450jDCctBuQHzDA+/jyy/XajHiV5/HOWRYADoPuBNE6AnH2UVClD+I+bRpzVKEMxqPOUOPOw7X+Gk+GusgryGOpf2u+OCRfar7oWE1epdhjwPEIV9t84nJEUnlKORG5iitaOrXlX2d+G1h4r9SfI3zb+wrJ1ezQxObsFTihHoS6LjwaZ37fE0E5T0gKo0eCkXUtV PYUGpeQVvo04aLKosZ2pKkcCNt2BCjB+JneBYKc/JElCXQq6N1d2x2T8zyQpM9WwCAwKpBo6GO1mG17wUfce8aCuxtPDhgPMoX x-ms-exchange-transport-forked: True X-OriginatorOrg: oracle.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: SA2PR10MB4474.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 9982df19-5a37-4921-b4e1-08d8f2080e9f X-MS-Exchange-CrossTenant-originalarrivaltime: 28 Mar 2021 16:39:29.0967 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 4e2c6054-71cb-48f1-bd6c-3a9705aca71b X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: wpy1MukSXBKiSwvqqNWmySLx0C+l1eRUjiaLt68910bZ4uZMA62YwPJWU+QC3md7KcIHb1h0bIGehywttQhcJg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN6PR10MB2669 X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9937 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 mlxlogscore=527 adultscore=0 mlxscore=0 malwarescore=0 bulkscore=0 phishscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2103250000 definitions=main-2103280126 X-Proofpoint-GUID: uY6kdPcJorkoBzYh0ooemYGyzJ3cuKAQ X-Proofpoint-ORIG-GUID: uY6kdPcJorkoBzYh0ooemYGyzJ3cuKAQ X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=9937 signatures=668683 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 impostorscore=0 mlxlogscore=835 clxscore=1011 priorityscore=1501 phishscore=0 spamscore=0 bulkscore=0 lowpriorityscore=0 suspectscore=0 mlxscore=0 malwarescore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2103250000 definitions=main-2103280126 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:203191 Archived-At: > > (plist-put (list 'a 'b 'c) "a" 42) > > > > Debugger entered--Lisp error: (wrong-type-argument plistp (a b c)) > > plist-put((a b c) "abc" 42) > > eval((plist-put (list (quote a) (quote b) (quote c)) "abc" 42)) > > > > That's all fine and dandy, except that there is no predicate `plistp'. >=20 > The backtrace there doesn't seem to be a result of the example form, What do you mean by that? > but, yes, the error here isn't very good. That's perhaps the main point, in spite of the Subject line. Whether there should be a `plistp' predicate is separate from whether and what error should be reported here. Feel free to change the Subject line to something more general, or to split this into two or more bugs: (1) bad error report, (2) how to handle `plist-put' etc., including whether to tolerate improper plists, (3) whether to add a `plistp' primitive. > Adding a `plistp' predicate would perhaps make sense, > but it would just be >=20 > (and (listp list) (zerop (mod (length list) 2))) Maybe, but maybe, like other such preds, it should be done in C. > and then we have the philosophical issue of "is nil a plist"? Does > anybody have any opinions? Yes, of course it's a plist, IMO. Why wouldn't it be? On the other hand, a probably more important question is the cost of getting the length of the list. That would be my main hesitation to say we should really have a `plistp' predicate. Errors like the one above should be handled correctly. The error is NOT that the list is not a plist. And I could argue that we should take the same approach we take to things that apply to lists, e.g. to elements of a list. We generally do NOT require list operations to be passed a proper list - typically a list whose last cdr is an atom can still be handled by most operations. I think the same should probably be true for plists. If the particular operation doesn't need to traverse the entire list then it shouldn't - no test for a proper plist. Let other kinds of errors be raised as appropriate. Errors like the one reported here are NOT about the plist not being proper (in this case not an even # of elements). They are about a particular plist element or a particular value that's tested against the plist. > > Not only that, but the error is _not_, apparently that the first > > arg isn't a proper plist. For example, this raises no error: > > > > (plist-put (list 'a 'b 'c) "a" 42) > > > > And it returns the list (a 42 c). Clearly the error was raised > > not because of an improper plist but because the key to look up > > is a string and the keys in the almost-plist are symbols. >=20 > Here you probably meant to say: > (plist-put (list 'a 'b 'c) 'a 42) Yes. > And that does indeed not result in any errors, but it's not because of > the stringiness of anything, but because 'a exists in the list, and > plist-put doesn't check whether the list is a plist in that case. Precisely. That's what I wrote immediately above. Let plists be handled the way lists are handled: if a particular operation doesn't need the plist to be proper then don't check for it to be proper. If an operation does need a proper plist then that operation will, itself, find out whether it can be effected, and raise an error if not. > Only when adding new elements does it check: >=20 > (plist-put (list 'a 'b 'c) 'd 42) > This signals an error. Even that wouldn't need to raise an error, if `put' added entries at the beginning instead of the end. The manual says: It may modify PLIST destructively, or it may construct a new list structure without altering the old. The function returns the modified property list, so you can store that back in the place where you got PLIST Even to replace an existing entry there's no need in general, to traverse the entire list. IOW, I think `put' could be smarter: Look for an existing entry, which would mean traversing the list if there is none, but that traversal could be tolerant and not care whether the plist is proper. And if no existing entry is found it could add the new entry at the beginning of the plist (or at the end of its proper portion, just before the atomic last cdr).=20