From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Kristoffer Balintona Newsgroups: gmane.emacs.devel Subject: Should vtable-goto-object use 'equal instead of 'eq? Date: Sat, 16 Nov 2024 22:48:57 +0100 Message-ID: Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="19424"; mail-complaints-to="usenet@ciao.gmane.io" To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Sat Nov 16 22:50:11 2024 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 1tCQgE-0004x1-Oc for ged-emacs-devel@m.gmane-mx.org; Sat, 16 Nov 2024 22:50:10 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tCQfG-00028E-L9; Sat, 16 Nov 2024 16:49:10 -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 1tCQfE-00027l-35 for emacs-devel@gnu.org; Sat, 16 Nov 2024 16:49:08 -0500 Original-Received: from mail-lf1-x12c.google.com ([2a00:1450:4864:20::12c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tCQfC-0001US-Eh for emacs-devel@gnu.org; Sat, 16 Nov 2024 16:49:07 -0500 Original-Received: by mail-lf1-x12c.google.com with SMTP id 2adb3069b0e04-539ee1acb86so628566e87.0 for ; Sat, 16 Nov 2024 13:49:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1731793739; x=1732398539; darn=gnu.org; h=to:subject:message-id:date:mime-version:from:from:to:cc:subject :date:message-id:reply-to; bh=uyg+5BlLfQItzaZS5Zd0zKHXYINdkaRiYjMAIsxXWYk=; b=Gib+fcUQufizkbVFTqA797wguzsSqoOG+PXd/PvcWAVnnsB45YjnbBsjDhcIcXkGBN IkK4y9yBG1mbymBBtEI9lHodcKgDYFts8CVmxsMxakZGtDQS5iWnFfsUz8/7O84Mj0V2 yRT/I55kAiI+P2qlmG0byPxADgaW7r0k5oe+V+b4BXPpkz6y3z4ojfbx2lXQkRpf+ECH tqXbWn7v5FrP3K9s/u/KUOcB+KMMUiyhTw3ZUVLgay+bYILJ4XKlMeFvtR86j+wkLYMJ YOsxpwBoNUQd4qAp+kY9+sN3xukZfLZ8c9EXAJQFNtpkb05sT4Voc6lmI9NRatu/kyuM MqDA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1731793739; x=1732398539; h=to:subject:message-id:date:mime-version:from:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=uyg+5BlLfQItzaZS5Zd0zKHXYINdkaRiYjMAIsxXWYk=; b=UO4ADhquXhDmd9IBvrj2NhpiGlrZGnAH+IEXbc7ccVVQP+dsGwgxuxEvTofHl57Ney uie4SEQixY4T26oARcHMdhXWTUpC0DDBwedT4njXcU6QgfD+gKLM0HfBucDaEFO2VPdP vK1+AcVfeAyyTdTkCFUt7SfwBZ3fA0+fLpiuFjSLPjzv10vxylZpqW75KNNGWV61eE5q quMwXzLw6jkEiXe3F3ZoT8EeViK7HlEjh1rUb+W0vnm00pjafTlG8x3PEW9F2kq3vJIB xsPXCtXFc2uRrxxdm+GCjWlzhkq+saYLTG2YNrd1VCT+aBGR6HGgt+uDMpRm4vT12Lve oj0Q== X-Gm-Message-State: AOJu0Yxu/GNSgGngaCsl67UFVKZbYOohGVgU89GiW97iFXwqBufl6QvD Jf6YKGYXXB+N+KC3DglEhfuX4j9Sj3gHj6woS40rKuvgOZ/ce5+L+vVUnwnMfOqfrmJqe32D7jQ YKxaETCcbtg582KiiSlzTnd4wU2QpFSvo X-Google-Smtp-Source: AGHT+IFrdcsZb4nB12QzF2XOiA83ZeovmuD+9CR1tJCaZTskZ6TGJ1C65mGm+8Ys3d0l3ERQGxpvVWiYu8jyg9RXdxk= X-Received: by 2002:a05:6512:b09:b0:539:9645:97ab with SMTP id 2adb3069b0e04-53dab2a7211mr2981067e87.33.1731793738512; Sat, 16 Nov 2024 13:48:58 -0800 (PST) Original-Received: from 753933720722 named unknown by gmailapi.google.com with HTTPREST; Sat, 16 Nov 2024 22:48:57 +0100 Received-SPF: pass client-ip=2a00:1450:4864:20::12c; envelope-from=krisbalintona@gmail.com; helo=mail-lf1-x12c.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-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:325479 Archived-At: Hello, I have been using vtable.el for a project of mine and have come across a bit of an undesirable design choice in vtable, namely, in vtable-goto-object. Its definition on master is as follows: (defun vtable-goto-object (object) "Go to OBJECT in the current table. Return the position of the object if found, and nil if not." (let ((start (point))) (vtable-beginning-of-table) (save-restriction (narrow-to-region (point) (save-excursion (vtable-end-of-table))) (if (text-property-search-forward 'vtable-object object #'eq) (progn (forward-line -1) (point)) (goto-char start) nil)))) The relevant line is the one calling text-property-search-forward. I am wondering whether using equal instead of eq as the predicate is preferable. Take the following example. The objects in a given vtable are strings. For whatever reason, I would like to go to the vtable object corresponding to the string "foo." I call (vtable-goto-object "foo") but it returns nil (does nothing). The reason is because vtable-goto-object uses eq instead of equal. This same situation occurs regardless of what kind of objec the vtable uses. As far as I can think of, the only way to productively use vtable-goto-object is if the objects are stored in e.g. a variable and referenced within that variable somehow, which is a significant constraint. The only case where eq would be desirable is if the vtable contains duplicate objects, that is, objects which return t on equal but nil on eq. With these cases in mind, would it be best for vtable-goto-object to have as a parameter the predicate used by text-property-search-forward (the default being eq)? -- Best, Kristoffer