holzschu / a-shell

A terminal for iOS, with multiple windows
BSD 3-Clause "New" or "Revised" License
2.6k stars 117 forks source link

Any possibility to add support to Scheme? #666

Open RadioNoiseE opened 1 year ago

RadioNoiseE commented 1 year ago

I was trying to write scheme in a-shell. After a glance at the Implementations section at scheme.org, I chose s7 since it exists as two files: s7.c and s7.h.

But the problem is the implementation includes setjmp.h which is not supported by web assembly. Also I know nothing about iOS development so compile it and side-load the new version of app is not very possible.

So I wonder if a-shell could include s7 as pre-complied binary (and maybe a simple repl mentioned here/here as well?).

But I am aware that scheme is not a widely used language (also s7 is not a perfect implementation of scheme compared to chez scheme), but since it's a 2-file problem, I think it's feasible and should (really?) benefit some people.

Thanks a lot for considering this(

RadioNoiseE commented 1 year ago

Oh and I think another thing I should mention is that s7 is under BSD license, and I'm not sure if there's any problem with it.

rcarmo commented 1 year ago

I've been poking at various options for this myself ever since I started using a-Shell. I'd love to use Guile, but since that is AGPL I don't think there is much of a chance.

Things I've tried:

The lack of "setjmp.h" is something I've come across quite a few times during the above, too, but even getting a copy off a Linux system the required functions just aren't there in the runtime (or weren't the last time I tried).

holzschu commented 2 months ago

Hi, The new SDK for wasi had support for setjmp, which means I could compile s7, at least (as you said, with only two files, it was the lowest hanging fruit). Now I’m wondering how to distribute it, since the executable expects the .scm files to be in the same place. I’ll also try to have the curses-version.

But in the meantime, you can use repl here: s7.tar.gz

RadioNoiseE commented 2 months ago

Thanks a lot! Finally I can write scheme on iOS.

rcarmo commented 2 months ago

That's amazing. I might try my hand at compiling PicoLisp (or, even better, GNU Guile) again. Guile in particular has an almost Python-level amount of batteries included, so I've been quite interested in getting it to work.

holzschu commented 2 months ago

If you manage to do it, please send it my way so I can add them to pkg. I've added s7 to pkg, so pkg install scheme-s7 will work (and I've given up on the curses version).

rcarmo commented 2 months ago

I'll let you know. I need to rebuild my WASI setup from scratch, going to see if I can do a Docker container or something like that for a reproducible environment.

holzschu commented 2 months ago

If you are on OSX, I now provide a ready-so-use SDK here: https://github.com/holzschu/wasi-sdk/releases/download/wasi-sdk-aShell-19/wasi-sdk.tar.gz

It contains the binaries (clang, ar, wasm-ld...) and the sysroot, with a bunch of auxiliary libraries.

rcarmo commented 2 months ago

Ah, right. I'm on everything, I just default to Linux for building stuff because I like my sandboxes away from my laptop :)