Rocksolid Light

Welcome to RetroBBS

mail  files  register  newsreader  groups  login

Message-ID:  

Most public domain software is free, at least at first glance.


devel / comp.lang.scheme / Cons equality in Kawa Scheme

SubjectAuthor
* Cons equality in Kawa SchemeMaciek Godek
`- Re: Cons equality in Kawa SchemeMaciek Godek

1
Cons equality in Kawa Scheme

<3c9f2733-d002-4a2d-a4aa-41178b7c5c1cn@googlegroups.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=75&group=comp.lang.scheme#75

  copy link   Newsgroups: comp.lang.scheme
X-Received: by 2002:ac8:1e93:: with SMTP id c19mr14137170qtm.60.1631947469080;
Fri, 17 Sep 2021 23:44:29 -0700 (PDT)
X-Received: by 2002:a05:6808:2204:: with SMTP id bd4mr6954893oib.108.1631947468806;
Fri, 17 Sep 2021 23:44:28 -0700 (PDT)
Path: i2pn2.org!i2pn.org!usenet.goja.nl.eu.org!3.eu.feeder.erje.net!feeder.erje.net!fdn.fr!usenet-fr.net!proxad.net!feeder1-2.proxad.net!209.85.160.216.MISMATCH!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.scheme
Date: Fri, 17 Sep 2021 23:44:28 -0700 (PDT)
Injection-Info: google-groups.googlegroups.com; posting-host=2a00:f41:48a1:d38a:c493:d2ba:6c58:570e;
posting-account=f7iIKQoAAAAkDKpUafc-4IXhmRAzdB5r
NNTP-Posting-Host: 2a00:f41:48a1:d38a:c493:d2ba:6c58:570e
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <3c9f2733-d002-4a2d-a4aa-41178b7c5c1cn@googlegroups.com>
Subject: Cons equality in Kawa Scheme
From: godek.maciek@gmail.com (Maciek Godek)
Injection-Date: Sat, 18 Sep 2021 06:44:29 +0000
Content-Type: text/plain; charset="UTF-8"
 by: Maciek Godek - Sat, 18 Sep 2021 06:44 UTC

Hi,
I would normally post this to the Kawa mailing list, but for some reason my messages fail to pass through. So maybe someone here will be able to help.

For some time, I've been working on a graphical Scheme programming environment called GRASP. I recently managed to embed the Kawa evaluator, and I really love the effects:

https://youtube.com/shorts/oOHg74HYau4?feature=share

I have been considering an even tighter integration with Kawa: while most of the source code is written in Java, it would make sense to port at least some bits of it to Kawa, bscause then I could develop the editor in itself.

Also, the representation of S-sxpressions that I've bee using internally, is really weird, and I would prefer to use regular cons cells instead. But I need to store some meta-data somewhere (mostly about whitespace between elements)

I thought that it would be nice to store that informatio in weak hash tables. I wrote a prototype parser in Guile:

https://github.com/panicz/grasp-android/blob/master/javor/parse-lite.scm

I tried porting this parser to Kawa, using their WeakHasbMap class. Unfortunately, it turnsd out that Kawa's gnu.lists.Pair class overrides the 'equals' method, providing it with equal?-like semantics (rather than eq?-like), which messes everything up.

So I've been wondering what would be the optimal workaround in this situation. I've been considering making a fork of Kawa, where I would remove those overrides, but I don't know to what extent Kawa relies on that semantics internally.

On the other hand, it would be preferable to come up with a less intrusive solution, so that I could go with tge generic kawa jar bundle.

Is there anyone here who could help?

Re: Cons equality in Kawa Scheme

<edb831bf-63e5-4b8e-af5d-eec120386a8cn@googlegroups.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=76&group=comp.lang.scheme#76

  copy link   Newsgroups: comp.lang.scheme
X-Received: by 2002:ac8:4308:: with SMTP id z8mr8380573qtm.121.1632050309554;
Sun, 19 Sep 2021 04:18:29 -0700 (PDT)
X-Received: by 2002:a9d:5e05:: with SMTP id d5mr16710241oti.61.1632050309206;
Sun, 19 Sep 2021 04:18:29 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!border2.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.scheme
Date: Sun, 19 Sep 2021 04:18:29 -0700 (PDT)
In-Reply-To: <3c9f2733-d002-4a2d-a4aa-41178b7c5c1cn@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=2a00:f41:483e:786b:24be:912e:32f3:1a3d;
posting-account=f7iIKQoAAAAkDKpUafc-4IXhmRAzdB5r
NNTP-Posting-Host: 2a00:f41:483e:786b:24be:912e:32f3:1a3d
References: <3c9f2733-d002-4a2d-a4aa-41178b7c5c1cn@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <edb831bf-63e5-4b8e-af5d-eec120386a8cn@googlegroups.com>
Subject: Re: Cons equality in Kawa Scheme
From: godek.maciek@gmail.com (Maciek Godek)
Injection-Date: Sun, 19 Sep 2021 11:18:29 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
Lines: 40
 by: Maciek Godek - Sun, 19 Sep 2021 11:18 UTC

So, I have managed to solve the issue without modifying Kawa sources,
by subclassing Kawa's Pair class and overriding its ‘equals' and 'hashCode' methods,
and then replace the reference to cons with the constructor of the derived class.

In Kawa, it looks like this

(import (class gnu.lists Pair))
(import (class java.lang System))

(define-simple-class cons (Pair)
((*init* a d) (invoke-special Pair (this) '*init* a d))
((equals object) ::boolean (eq? object this))
((hash-code) ::int (System:identity-hash-code this)))

or in Java:

import gnu.lists.Pair;
import java.lang.System;

class Cons extends Pair {
public Cons(Object a, Object d) {
super(a, d);
}

@Override
public boolean equals(Object x) {
return this == x;
}

@Override
public int hashCode() {
return System.identityHashCode(this);
}
}

Here's a complete solution that works identically on both Kawa and Guile:

https://github.com/panicz/grasp-android/blob/master/javor/parse-kawa.scm

1
server_pubkey.txt

rocksolid light 0.9.8
clearnet tor