From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: =?utf-8?Q?Mattias_Engdeg=C3=A5rd?= Newsgroups: gmane.emacs.devel Subject: Re: Warn about comparing quoted lists (etc) using `eq` Date: Thu, 15 Dec 2022 10:36:07 +0100 Message-ID: <58A7E984-95CC-4F7F-817B-10E680E5966E@gmail.com> References: <8D624413-5A6C-46D7-A4EB-53C23F7CC4D3@gmail.com> Mime-Version: 1.0 (Mac OS X Mail 14.0 \(3654.120.0.1.13\)) 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="15037"; mail-complaints-to="usenet@ciao.gmane.io" Cc: emacs-devel , "Dr. Arne Babenhauserheide" To: Juanma Barranquero Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Thu Dec 15 11:42:37 2022 Return-path: Envelope-to: ged-emacs-devel@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 1p5lhE-0003ii-DR for ged-emacs-devel@m.gmane-mx.org; Thu, 15 Dec 2022 11:42:36 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p5lgb-0006Gk-A4; Thu, 15 Dec 2022 05:41:57 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p5key-0007Pw-PY for emacs-devel@gnu.org; Thu, 15 Dec 2022 04:36:12 -0500 Original-Received: from mail-lf1-x132.google.com ([2a00:1450:4864:20::132]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1p5kew-0008VK-WF for emacs-devel@gnu.org; Thu, 15 Dec 2022 04:36:12 -0500 Original-Received: by mail-lf1-x132.google.com with SMTP id c1so14749772lfi.7 for ; Thu, 15 Dec 2022 01:36:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:sender:from:to:cc:subject :date:message-id:reply-to; bh=l2oAwyUx1NokLKLJxS9DTc8g+59BLoFLWkifPIbSesw=; b=RSVh7Ns8FBy9tRyA/VT2uPcaUvZDiwP8hwf7Tz4LzzrLOUQwQ8UWXa84jKQUS9gUXF jgryAwh6/cOxjMlt+1NZuZgv3pxM35dbTbc00BM69m65MSLaFxDpbaS+OHDkJqDBl2Xq feN1n7vk0R2dZ2QhoD1IULQI0uYgc0ieSBtlDa09oTbWuv5Hlmvvl/BzNFjdhkKEbRrt aFajpYs0RyFFEuN1n8lykB8dfalPjip6g5Au8nRp1y/U3DrmbA2xgGtNGvmb+SR9MrGm RNhvlMz56FDfkUKN6n0qsYZWQoC4f4o0q95HXKTWaSfNGMfSAjCwOQO0kkZkANMco/7v UCQA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:sender:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=l2oAwyUx1NokLKLJxS9DTc8g+59BLoFLWkifPIbSesw=; b=hnHLJCHy2GyfwsAIR5d8/7Tzm49Cp4puc6gq0mWDyoXiPcFSysqLshbmbUFs2PTjc8 KPU2e0lo5YMMY6jA8EzTLUevwCB1DUgCTxpa3zNiGTioXYlP3wb8LuvYtD3da86oKZ6z caDkjgsSD/2bUx5wSeFlG3MsHbaeaDFAZ2OUJLxQl9HN5aKfNWgSnCOi5f78SpYLILX4 ZK/yNgFgZZwju7voAwaHohRZ37PX3VZm1RS6X1NTw9lPHOLKk16GgYtcEixkqDcO7Q6A aeAp0mBz08eamcA3Fj35k3N/97H+emXuVDMTIsQDN6ykm5VwEBXxB9Jva9oqWX5+B5E2 haiA== X-Gm-Message-State: AFqh2kr6rSXwLdFBunzTnT3VBt7dLulWC+gG2a9j56OFAODRVS+7s8fz dykRlTjwEIFWBkjtrumM3FI= X-Google-Smtp-Source: AMrXdXslRb1qoKn4qT9Mrf5ZYQNZOAmTeLRdD7RFjD8SCTJtPCrvfMNbXHBRIuE9RihqZFLQHUWg3A== X-Received: by 2002:a19:c515:0:b0:4bb:7028:f6b6 with SMTP id w21-20020a19c515000000b004bb7028f6b6mr607286lfe.49.1671096969352; Thu, 15 Dec 2022 01:36:09 -0800 (PST) Original-Received: from smtpclient.apple (c188-150-171-209.bredband.tele2.se. [188.150.171.209]) by smtp.gmail.com with ESMTPSA id q2-20020ac25142000000b0049482adb3basm1106859lfd.63.2022.12.15.01.36.08 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 15 Dec 2022 01:36:08 -0800 (PST) In-Reply-To: X-Mailer: Apple Mail (2.3654.120.0.1.13) Received-SPF: pass client-ip=2a00:1450:4864:20::132; envelope-from=mattias.engdegard@gmail.com; helo=mail-lf1-x132.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Mailman-Approved-At: Thu, 15 Dec 2022 05:41:55 -0500 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 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-mx.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.devel:301452 Archived-At: 15 dec. 2022 kl. 05.17 skrev Juanma Barranquero : > Note that your patch has a false positive with the empty string, which = is optimized to be always the same object That's only an implementation aspect that we give no guarantees about on = the Lisp language level, and in fact as you correctly observe: > there are two, a unibyte one and a multibyte one Precisely, and often there's no telling which one we compare against in = (eq x "") -- that expression may return t or nil when x is an empty = string. Thus it's definitely a well-motivated warning, toy examples like > (let ((x "")) (eq x "")) notwithstanding. We simply do not guarantee the identity of literal = strings and the empty string is no exception. 15 dec. 2022 kl. 07.34 skrev Dr. Arne Babenhauserheide = : > I miss a suggestion, though: the warning as it is is not actionable. = It > would be great if it could say something along the lines of >=20 > "... (arg 2). Consider using `equal'." While this sounds like a useful suggestion on the surface, it's actually = slightly dangerous: blindly replacing `eq` with `equal` (and `memq` with = `member`, and so on) may very well break working code (that silently = relied on the condition not being true). It's also a poor remedy against = pratfalls like (memq x '(one 'two 'three)) which do occur. What we really want is to make a human look at the code, = and think.