unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
From: Rob Browning <rlb@defaultvalue.org>
To: Lassi Kortela <lassi@lassi.io>,
	Jessica Tallon <tsyesika@tsyesika.se>,
	guile-devel@gnu.org
Subject: Re: Clojure support
Date: Sat, 13 May 2023 17:10:55 -0500	[thread overview]
Message-ID: <87o7mnubkg.fsf@trouble.defaultvalue.org> (raw)
In-Reply-To: <dfa81c05-ba5b-01cf-5703-5e97409f8c54@lassi.io>

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



  parent reply	other threads:[~2023-05-13 22:10 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-27 13:17 Functional datatypes in Guile Jessica Tallon
2023-02-28  7:47 ` Maxime Devos
2023-02-28  8:22 ` pukkamustard
2023-02-28 16:04   ` Thompson, David
2023-02-28 16:54     ` Philip McGrath
2023-03-04 16:38     ` pukkamustard
2023-03-05 12:58       ` Linus Björnstam
2023-03-07 15:02         ` pukkamustard
2023-06-10 16:47   ` Ludovic Courtès
2023-06-10 18:28     ` Dr. Arne Babenhauserheide
2023-06-16  5:15     ` pukkamustard
2023-06-21 21:53       ` Ludovic Courtès
2023-02-28 17:03 ` Clojure support Lassi Kortela
2023-03-04 10:28   ` Linus Björnstam
2023-03-04 11:22     ` Philip McGrath
2023-05-07 15:36       ` Linus Björnstam
2023-05-13 22:10   ` Rob Browning [this message]
2023-05-20  9:36     ` Maxime Devos
2023-05-21  2:29       ` Rob Browning

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/guile/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87o7mnubkg.fsf@trouble.defaultvalue.org \
    --to=rlb@defaultvalue.org \
    --cc=guile-devel@gnu.org \
    --cc=lassi@lassi.io \
    --cc=tsyesika@tsyesika.se \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).