Generators in Lone Lisp(matheusmoreira.com)
39 points by matheusmoreira 3 days ago | 3 comments
hencq 4 hours ago
I like the overview given in this Stackoverflow answer [1] (based on an even earlier comment) which classifies different types of continuations:

- Asymmetric or symmetric

- Stackful or stackless

- Delimited or undelimited

- Multi-prompt or single prompt

- Reentrant or non-reentrant

- Clonable or not

Based on that these generators (or semi-coroutines as the article also calls them) seem to be asymmetric, stackful, delimited, single prompt(?), non-reentrant continuations.

[1] - https://stackoverflow.com/questions/62817878/what-are-the-sp...

matheusmoreira 1 hour ago
That's a great overview. Yeah they are asymmetric, Wikipedia says symmetric and asymmetric correspond to coroutines and semicoroutines. They are also stackful and delimited. They are single shot by design, though I could easily make it possible to restart the generator from scratch if needed.

As for single prompt vs multiprompt... I'm not too sure about this one. I have a check to prevent recursion but nesting generators shouldn't be a problem since they keep track of their own callers.

I think lone's generators have composability issues due to the stack separation. For example, calling a generator g2 inside another generator g1 doesn't transparently yield values from g2 to g1's caller. I've been wondering about how to fix this without a Python-like yield from primitive.

geon 38 minutes ago
This is awesome!

I haven't seen Lone Lisp before. Is it meant to be like a Symbolics Lisp Machine, where the entire userspace is lisp?

I really like using generators in typescript. They make a lot of problems much easier.

matheusmoreira 15 minutes ago
The idea is to create a language good enough to build a Lisp user space for Linux. I didn't dare to call it a lisp machine at first but other users suggested that when it was first submitted here on HN. Here's the discussion:

https://news.ycombinator.com/item?id=38126052

I'm doing some plumbing work on lone right now, then I'll start designing the iterator protocol. Gotta fix some usability details in the generators to make them more pleasant to use but I'm really proud of the fact that they even work at all. I'll read about typescript generators and try to understand what makes them great to use.

bjoli 35 minutes ago
Fun read! If anyone is interested in more, I believe Andy Wingo has written about the implementation of delimited continuations in guile scheme over at https://wingolog.org
matheusmoreira 23 minutes ago
I love his blog. I think I've read almost the entirety of it. Here's his article about delimited continuations:

https://www.wingolog.org/archives/2010/02/26/guile-and-delim...

I even cited it in my own delimited continuations article:

https://www.matheusmoreira.com/articles/delimited-continuati...

After publishing that I actually emailed him about it. I wanted to show him how I solved the interleaving stacks problem he outlined in that article. No idea if he ever saw the email but his about page does mention the fact he doesn't check it often.