From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.ciao.gmane.io!not-for-mail From: lloda Newsgroups: gmane.lisp.guile.bugs Subject: bug#39634: All keyowrds hash to the same value Date: Tue, 25 Feb 2020 23:13:59 +0100 Message-ID: <33B73487-1CD8-4212-8FC8-5A426D0A4F7F@sarc.name> References: <87wo8mcs1j.fsf@trouble.defaultvalue.org> <875zg19qpl.fsf@gnu.org> <87h7zeo06f.fsf@igalia.com> Mime-Version: 1.0 (Mac OS X Mail 12.4 \(3445.104.11\)) Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="ciao.gmane.io:159.69.161.202"; logging-data="125412"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 39634@debbugs.gnu.org, Ludovic =?UTF-8?Q?Court=C3=A8s?= , Rob Browning To: Andy Wingo Original-X-From: bug-guile-bounces+guile-bugs=m.gmane-mx.org@gnu.org Tue Feb 25 23:15:13 2020 Return-path: Envelope-to: guile-bugs@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 1j6iTx-000WVq-2x for guile-bugs@m.gmane-mx.org; Tue, 25 Feb 2020 23:15:13 +0100 Original-Received: from localhost ([::1]:35588 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j6iTv-00081e-MR for guile-bugs@m.gmane-mx.org; Tue, 25 Feb 2020 17:15:11 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:60413) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j6iTn-00081R-U8 for bug-guile@gnu.org; Tue, 25 Feb 2020 17:15:05 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j6iTm-0004tI-Lv for bug-guile@gnu.org; Tue, 25 Feb 2020 17:15:03 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:50270) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1j6iTm-0004tC-It for bug-guile@gnu.org; Tue, 25 Feb 2020 17:15:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1j6iTm-0008Vb-Ep for bug-guile@gnu.org; Tue, 25 Feb 2020 17:15:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: lloda Original-Sender: "Debbugs-submit" Resent-CC: bug-guile@gnu.org Resent-Date: Tue, 25 Feb 2020 22:15:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 39634 X-GNU-PR-Package: guile Original-Received: via spool by 39634-submit@debbugs.gnu.org id=B39634.158266885232625 (code B ref 39634); Tue, 25 Feb 2020 22:15:02 +0000 Original-Received: (at 39634) by debbugs.gnu.org; 25 Feb 2020 22:14:12 +0000 Original-Received: from localhost ([127.0.0.1]:56243 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1j6iSy-0008U8-8C for submit@debbugs.gnu.org; Tue, 25 Feb 2020 17:14:12 -0500 Original-Received: from mta-07-4.privateemail.com ([68.65.122.27]:31634) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1j6iSw-0008Tt-LC for 39634@debbugs.gnu.org; Tue, 25 Feb 2020 17:14:11 -0500 Original-Received: from MTA-07.privateemail.com (localhost [127.0.0.1]) by MTA-07.privateemail.com (Postfix) with ESMTP id 9314260043; Tue, 25 Feb 2020 17:14:02 -0500 (EST) Original-Received: from [192.168.1.105] (unknown [10.20.151.222]) by MTA-07.privateemail.com (Postfix) with ESMTPA id 919A460034; Tue, 25 Feb 2020 22:14:01 +0000 (UTC) In-Reply-To: <87h7zeo06f.fsf@igalia.com> X-Mailer: Apple Mail (2.3445.104.11) X-Virus-Scanned: ClamAV using ClamSMTP X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.51.188.43 X-BeenThere: bug-guile@gnu.org List-Id: "Bug reports for GUILE, GNU's Ubiquitous Extension Language" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-guile-bounces+guile-bugs=m.gmane-mx.org@gnu.org Original-Sender: "bug-guile" Xref: news.gmane.io gmane.lisp.guile.bugs:9596 Archived-At: > On 25 Feb 2020, at 21:56, Andy Wingo wrote: >=20 > On Thu 20 Feb 2020 17:19, Ludovic Court=C3=A8s writes: >=20 >> Of all the scm_tc7_ values listed in =E2=80=98scm.h=E2=80=99, the = following are not >> explicitly listed (so they go to the default case that hashes the = first >> word): >=20 > Reformatting your list so I can check one by one :) >=20 >> variable, >> hashtable, >> fluid, >> dynamic_state, >> frame, >> atomic_box, >> program, >> vm_cont, >> weak_set, >> weak_table, >> port >=20 > No equal? implementation, so should hashq() instead. >=20 >> bytevector, >> array, >> bitvector, >=20 > These have equal? implementations, and what's more, a bitvector can > equal? an array... I think we have another bug! >=20 > ;; Project 2d array as 1d array (scm_tc7_array) > (define x > (make-shared-array #2b((#t #t #t)) (lambda (i) (list 0 i)) '(0 2))) > ;; scm_tc7_bitvector > (define y #*111) >=20 > (equal? x y) ;; =3D> #t > (equal? (hash x #xffffffff) (hash y #xffffffff)) ;; =3D> #f >=20 > Similarly for 1-d scm_tc7_array versus regular vectors, bytevectors, > etc. >=20 > Fixing this will not be straightforward... I think basically 1d = arrays > need some special hashing logic so that e.g. vectors and 1d arrays = hash > to the same thing. I cannot check at the moment but I think that use of make-shared-array = is special cased to return a bitvector because the shared array and the = root happen to be equivalent. So your x isn't a scm_tc7_array but a = scm_tc7_bitvector. The same is true for the other vector types. You can = see that if you make a shared array with bounds '(0 1) instead of '(0 2) = for example, or non-unit step or non-zero lower bound or anything that = cannot be represented as a root vector. Now it is true that functionally a root vector and a 1d array with the = same bounds and the same elements are equivalent even if the array has = non-unit stride and so on, but we had that logic before were you could = use the root vector functions on arrays and it was an absolute mess. I = think there should be a logic to hash n-d arrays that extends to 1-d = arrays so there's no need to make special cases. All vectors can be = treated as 1-d arrays so that should work fine for those too. Partially related, I have a series of patches on wip-vector-cleanup to = make sure that the various vector implementations don't depend on arrays = (as they still do on some cases) but rather the other way around, = strictly. I haven't posted about it b/c it changes a few interfaces and = I haven't figured out the deprecation route. regards >=20 >> stringbuf, >> values, >=20 > These are never exposed to Scheme, and never compared using equal? > AFAIU. No need for special cases. >=20 > Basically I think the tc7 case should default to hashq, and include > special cases for the ones that have equal? implementations or which > have read syntax. >=20 > Sound right to you? >=20 > Andy >=20 >=20 >=20