From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Rob Browning Newsgroups: gmane.lisp.guile.devel Subject: Re: Clojure support Date: Sat, 13 May 2023 17:10:55 -0500 Message-ID: <87o7mnubkg.fsf@trouble.defaultvalue.org> References: <2682583.mvXUDI8C0e@t480s> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="22016"; mail-complaints-to="usenet@ciao.gmane.io" To: Lassi Kortela , Jessica Tallon , guile-devel@gnu.org Original-X-From: guile-devel-bounces+guile-devel=m.gmane-mx.org@gnu.org Sun May 14 00:11:45 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 1pxxSr-0005WW-Im for guile-devel@m.gmane-mx.org; Sun, 14 May 2023 00:11:45 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pxxSB-0000mt-AK; Sat, 13 May 2023 18:11:03 -0400 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 1pxxS9-0000mk-3G for guile-devel@gnu.org; Sat, 13 May 2023 18:11:01 -0400 Original-Received: from defaultvalue.org ([45.33.119.55]) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pxxS7-0005vJ-2P for guile-devel@gnu.org; Sat, 13 May 2023 18:11:00 -0400 Original-Received: from trouble.defaultvalue.org (localhost [127.0.0.1]) (Authenticated sender: rlb@defaultvalue.org) by defaultvalue.org (Postfix) with ESMTPSA id 8766520364; Sat, 13 May 2023 17:10:56 -0500 (CDT) Original-Received: by trouble.defaultvalue.org (Postfix, from userid 1000) id EA62A14E089; Sat, 13 May 2023 17:10:55 -0500 (CDT) In-Reply-To: Received-SPF: pass client-ip=45.33.119.55; envelope-from=rlb@defaultvalue.org; helo=defaultvalue.org X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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:21830 Archived-At: Lassi Kortela writes: > Those are core data types of Clojure. It'd be nice if the canonical > Scheme versions of these types have Clojure-compatible semantics. This > will make it easy to turn Scheme implementations into partial > implementations of Clojure. This is already being attempted in Lokke > (https://github.com/lokke-org/lokke). Not sure if it helps, but lokke should include all the basics, and in some cases, I've tried to implement things in a scheme-compatible way, then build the clojure support on that. For example (lokke scm vector) provides a scheme-style lokke-vector-length/ref/append interface, and then (lokke vector) builds on it to provide the clojure generics like conj, nth, count, etc. The current vectors are intended to be a fairly close translation of clojure's persistent vectors to C: https://hypirion.com/musings/understanding-persistent-vector-pt-1 via https://codeberg.org/lokke/lokke/src/branch/main/lib/lokke-vector.c including the tail optimization, etc. That code's standalone, fairly compact, and should be reasonably easy to use elsewhere (well for a C module, anyway). In addition, (lokke scm edn) provides a configurable edn parser that can build purely scheme data structures if you like, and then it's used by (lokke ns clojure edn), which implements lokke's clojure.edn namespace, to build clojure hash-maps, hash-sets, etc. Generally speaking, I'd be more than happy to rework and contribute anything in lokke that ends up being interesting to guile, and I've tried to keep everything arranged so that could happen, i.e. licensing, etc. Personally, I'd love to see guile provide edn support. Regarding hash-maps and hash-sets, I initially used pfds, but after having trouble with bugs, I switched to fash: https://codeberg.org/lokke/lokke/commits/branch/main/search?q=pfds Regarding fash, unless http://wingolog.org/pub/fash.scm has changed (haven't checked recently), there were some bugs that you'd want fixed. There was also a brief discussion about setting up a "common" repo somewhere that incorporated various improvements (iirc, someone else may have some too?), but nothing has happened on that front yet that I know of. I might do something eventually. For now, this version should work fine, and adds a fash-set function: https://github.com/lokke-org/lokke/blob/main/mod/lokke/fash.scm https://codeberg.org/lokke/lokke/src/branch/main/mod/lokke/fash.scm One thing that's missing if lokke's going to stick with fash, is a "fash-delete" (i.e. dissoc). Right now lokke just does something somewhat terrible whereby "deletion" changes the key to refer to a "tombstone" value. Unrelated to the persistent data structures, there's also a fairly standalone interface to libpcre2 in (lokke pcre2) and the corresponding lokke-pcre2.c. Lokke uses and requires pcre because I wanted it to have a standard regex syntax/behavior across platforms. I've also thought I might like to see that as a (presumably optional) guile feature, though it'll make more sense if I ever finish the work I've started to migrate guile to utf-8 (or if someone else beats me to it) because pcre doesn't support latin-1. Right now, that code has to do some undesirable conversions in some cases. Hope this helps -- Rob Browning rlb @defaultvalue.org and @debian.org GPG as of 2011-07-10 E6A9 DA3C C9FD 1FF8 C676 D2C4 C0F0 39E9 ED1B 597A GPG as of 2002-11-03 14DD 432F AE39 534D B592 F9A0 25C8 D377 8C7E 73A4