guile-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Clojure support


From: Rob Browning
Subject: Re: Clojure support
Date: Sat, 13 May 2023 17:10:55 -0500

Lassi Kortela <lassi@lassi.io> 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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]