From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: "Philip McGrath" Newsgroups: gmane.lisp.guile.devel Subject: Re: Functional datatypes in Guile Date: Tue, 28 Feb 2023 11:54:48 -0500 Message-ID: References: <2682583.mvXUDI8C0e@t480s> <86bklenq75.fsf@posteo.net> Mime-Version: 1.0 Content-Type: text/plain;charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="32961"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Cyrus-JMAP/3.9.0-alpha0-183-gbf7d00f500-fm-20230220.001-gbf7d00f5 To: guile-devel@gnu.org Original-X-From: guile-devel-bounces+guile-devel=m.gmane-mx.org@gnu.org Tue Feb 28 17:56:12 2023 Return-path: Envelope-to: guile-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 1pX3Gr-0008IX-MI for guile-devel@m.gmane-mx.org; Tue, 28 Feb 2023 17:56:10 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pX3GS-0002QP-M9; Tue, 28 Feb 2023 11:55:45 -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 1pX3GQ-0002Ps-3M for guile-devel@gnu.org; Tue, 28 Feb 2023 11:55:42 -0500 Original-Received: from wout2-smtp.messagingengine.com ([64.147.123.25]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pX3GN-0000nY-K0 for guile-devel@gnu.org; Tue, 28 Feb 2023 11:55:41 -0500 Original-Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.west.internal (Postfix) with ESMTP id 0913332009EE for ; Tue, 28 Feb 2023 11:55:33 -0500 (EST) Original-Received: from imap52 ([10.202.2.102]) by compute1.internal (MEProxy); Tue, 28 Feb 2023 11:55:34 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= philipmcgrath.com; h=cc:content-transfer-encoding:content-type :date:date:from:from:in-reply-to:in-reply-to:message-id :mime-version:references:reply-to:sender:subject:subject:to:to; s=fm1; t=1677603333; x=1677689733; bh=iUTB1KClOR5iijvWqHfVLWB2I ursOuwLNStmVAEDPMM=; b=FEFlzYhaa3rvdkW+Ndns+m/rm4+bLfKW0hlN6FLdR 9dZprvVmkLlGHzH/3qAkzPybc9vwqRYLMuve+lVsmXC4hm8bY9NJo9rWz40+rgCp RGOEdjVacWKWJYWz7BFXc1LoHbVMpMm/4rHREgDK5a02Zn8lf7jx+g1wh6dtnZwZ lJ9psIYkBmy6ANuyD+uXBdvcub1B3Dmq5r1Mno3eq/ggMzQyHnxP3oxMI9pb1HKo zr8lvECzce5XwyF3sk0cwB6RzuzCxgKOhMW8SHFHOICxYcCwC2TIktZ9WjqERmcc KkT+e/3ZFmYZyL5G5Oo9Kx5Ffb6NOXInGYQ+utkD0nIeg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:date:feedback-id:feedback-id:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:sender :subject:subject:to:to:x-me-proxy:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm1; t=1677603333; x=1677689733; bh=i UTB1KClOR5iijvWqHfVLWB2IursOuwLNStmVAEDPMM=; b=VgsoExiEMe+Lr1XOi z5bO4yNB9jbFMBSW4X/nWq6QHjHakRKjdGjYH05ipQARYA8JcqamItvkmIU0LRoB bfFqHHX7ZlkMGuRnj5/TgdLLHrMDnDpCTqgcVJexnIM5I4SMq5qQbqExt9aGdyrV NV+Te02KSFnh1MCYem4E1/yZn/h9ASuIL9XwtjUoQlXfBnziq4wiESQ8+gXhXa8H tBTEDqesPnRisGDGWRVsB5ttluaexct5lN8zPLEq4T2ZZzxrR4j8/RGcSMUbARI3 ryoEnMyjo6JS7lGAOfbA2S9W/RCX2y6/B3MeSrZ1R8D1NlmqfB1ipboIazRRADIS w4JHw== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvhedrudelfedgfeduucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpefofgggkfgjfhffhffvufgtgfesth hqredtreerjeenucfhrhhomhepfdfrhhhilhhiphcuofgtifhrrghthhdfuceophhhihhl ihhpsehphhhilhhiphhmtghgrhgrthhhrdgtohhmqeenucggtffrrghtthgvrhhnpedvhe eltdeuudefleelveeggfejfeejteefudeutdeihfejhfevgfdtvefggedtkeenucffohhm rghinhepshgthhgvmhgvrhhsrdhorhhgpdhinhhqlhgrsgdrnhgvthdpghhithhhuhgsrd gtohhmpdhinhhtmhgrphdrshhspdhuthgrhhdrvgguuhdprhgrtghkvghtqdhlrghnghdr ohhrghenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpe hphhhilhhiphesphhhihhlihhpmhgtghhrrghthhdrtghomh X-ME-Proxy: Feedback-ID: i2b1146f3:Fastmail Original-Received: by mailuser.nyi.internal (Postfix, from userid 501) id 6C7E4C60091; Tue, 28 Feb 2023 11:55:33 -0500 (EST) X-Mailer: MessagingEngine.com Webmail Interface In-Reply-To: Received-SPF: pass client-ip=64.147.123.25; envelope-from=philip@philipmcgrath.com; helo=wout2-smtp.messagingengine.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 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, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: guile-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Developers list for Guile, the GNU extensibility library" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guile-devel-bounces+guile-devel=m.gmane-mx.org@gnu.org Original-Sender: guile-devel-bounces+guile-devel=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.lisp.guile.devel:21761 Archived-At: Hi, On Tue, Feb 28, 2023, at 11:04 AM, Thompson, David wrote: > Hi pukkamustard, > > On Tue, Feb 28, 2023 at 3:34 AM pukkamustard = wrote: >> >> >> I've been using SRFI-146 >> (https://srfi.schemers.org/srfi-146/srfi-146.html) for functional >> mappings. There's a Guile port: >> https://inqlab.net/git/guile-srfi-146.git/ (also in Guix - >> guile-srfi-146). > > Your Guile port of (srfi srfi-146 hash) looks really nice! A > functional hash is the most important data structure for our needs at > Spritely. Do you know if it's thread-safe (unlike vhashes)? Another issue with vhashes is that vhash-cons works like cons with an al= ist: if the vhash already had an entry for the given key, the returned v= hash will retain a reference to both the new value and the old value, po= tentially preventing the old value from being garbage-collected. > Andy's > fash implementation uses atomic boxes, for example. > I have a work-in-progress port of the three immutable hash-table impleme= ntations from Racket CS. The two portable backends, Patricia tries and v= ector-based hash array mapped tries, offer a time-space tradeoff. There'= s commentary in https://github.com/racket/racket/blob/master/racket/src= /cs/rumble/intmap.ss The backend actually used now by Racket CS is a variant of the HAMT impl= ementation backed by a new primitive type, "stencil vectors", a kind of = sparse array. They need a little cooperation from the runtime system, bu= t they're designed to distill the essence of what functional data struct= ure implementations need from the runtime and GC into a minimal primitiv= e type. There's a paper with details and more benchmarks: it reports tha= t Racket's stencil-vector HAMTs "perform in the same neighborhood as" Cl= ojure's PersistentHashMap and Java's CHAMP. There's Racket documentation for stencil vectors at or the Guix package "racket", = and the corresponding Chez Scheme documentation is in the Guix package "= chez-scheme-for-racket:doc". Even the non=E2=80=93stencil-vector backends should be serviceable, thou= gh! -Philip