kanaka / mal

mal - Make a Lisp
Other
10k stars 2.54k forks source link

HolyC implementation (TempleOS) #309

Closed bagnalla closed 5 years ago

bagnalla commented 6 years ago

I've written a HolyC implementation of Mal. It passes all tests, self-hosts, and has garbage collection. It's a bit unusual compared to other implementations because there's currently no way to run HolyC natively on Linux.

Is there any interest in including such an implementation in the main repo? The old "step" files aren't included in the repo linked above. I still have them, but they're somewhat outdated because other parts of the code have changed throughout development.

One thing that is probably not HolyC-idiomatic is the use of aliases for the primitive types U0, U8, I64, etc. That can easily be changed, of course.

dubek commented 6 years ago

Nice!

Maybe prepare a Docker image with qemu and a TempleOS image in it? And then copy the mounted /mal volume content into the TempleOS disk image... A lot of work, for sure.

bagnalla commented 6 years ago

I think I've managed to put together a Docker image (first time), but it appears to require some special arguments to run since it's a GUI application. I'm able to run it with the following command:

docker run -it --privileged --rm -e DISPLAY=$DISPLAY -v /tmp/.X11-unix:/tmp/.X11-unix -v /root/.Xauthority:/root/.Xauthority:rw bagnalla/mal-holyc:v1

So I'm guessing that it isn't quite compatible with the existing infrastructure (make DOCKERIZE=1 ...).

dubek commented 6 years ago

Yeah that wouldn't work with the existing automation. Also I believe our current Docker images have python installed in them, and that python is actually driving the tests (inside the Docker container).

But a published Dockerfile (and possibly a public image on Docker Hub) would allow other users to quickly test the implementation, even if it's not via the standard make DOCKERIZE=1 ... mechanism.

No one ported a HolyC compiler to Linux?

bagnalla commented 6 years ago

There's this which is incomplete. I've thought about writing a HolyC -> C or C++ translator but I think there are many quirky behaviors in HolyC that would be hard to preserve. I could make it work for the purpose of this project, but it wouldn't be sound in general.

It's probably possible to port the existing HolyC compiler somehow, but it would be a lot of work for sure.

To be honest, running outside of TempleOS kind of defeats the purpose anyway. I don't think the implementation is particularly special otherwise (maybe the GC). It's basically just a weird C implementation. But, AFAIK it's actually the first general-purpose high-level programming language on TempleOS (besides HolyC of course if you consider that "high-level").

kanaka commented 5 years ago

@bagnalla I'm doing some cleanup of mal issues. I'm probably going to close this soon unless you indicate you still want to work on getting it integrated. If you are interested in working this, one approach that might work is if TempleOS has serial port support. If it does, then you could look at the approach I used for launching fooboot applications booted within qemu but still being able to test/drive it from the outside: https://github.com/kanaka/fooboot/blob/master/runfoo

bagnalla commented 5 years ago

I probably won't have time to work on this in the foreseeable future, so feel free to close it. There's still the standalone repo but I guess it may fall out of sync over time.

kanaka commented 5 years ago

@bagnalla okay, I've added a link to your implementation to the README (under External Implementations). I'll close the issue. If in the future, you are able to get this running against the standard test harness, feel free to send a PR with the change.