revert spawn!
as a special form
This commit is contained in:
parent
3a5415e1c7
commit
a38a686a76
|
@ -1208,3 +1208,34 @@ After that:
|
||||||
- [x] read inputs?
|
- [x] read inputs?
|
||||||
- [x] load url text?
|
- [x] load url text?
|
||||||
|
|
||||||
|
### Following links
|
||||||
|
#### 2025-07-05
|
||||||
|
Doing some last minute design work on linking processes.
|
||||||
|
Here's the erlang way:
|
||||||
|
* `link` is `link/1`: we always link _from a process_.
|
||||||
|
* links are always bidirectional
|
||||||
|
* [ ] update the link API to reflect this
|
||||||
|
* There's the concept of an exit signal
|
||||||
|
- erlang has three ways of doing this (ish): `:normal` (returning), `:kill` (panic), or a reason (which is a value).
|
||||||
|
- you can "trap" an exit signal that's `:normal` or a reason, but not if it's `:kill`, which will bring down the monitoring process
|
||||||
|
* I think in ludus we want...
|
||||||
|
|
||||||
|
Well? What do we want?
|
||||||
|
|
||||||
|
Erlang and Elixir have designs that are meant for massively concurrent processes.
|
||||||
|
In addition, I've been thinking about how the willy-nilly, anything goes, messages getting passed around all kinds of places, actually cuts against the spirit of Ludus.
|
||||||
|
What sort of process management, abstraction, modelling, and mental-modelling do we want in ludus?
|
||||||
|
My sense is that, actually, I have to build the things we're going to build before I have a sense of what needs doing.
|
||||||
|
`link` may not even be a thing we need?
|
||||||
|
|
||||||
|
Anyway, here's the tl;dr for basic process linking:
|
||||||
|
* `link/1` should establish a bidirectional link, bringing one process down if the other exits for any reason, causing a panic if the linked process exits unexpectedly, even on a normal return
|
||||||
|
* `monitor/1` means we can monitor exit messages, these will be `(:exit, pid, (:ok, value))` in the case of successful return, or `(:exit, pid, (:err, msg))` in the case of a panic. These are sent as normal messages to the monitoring process.
|
||||||
|
|
||||||
|
Erlang/Elixir has a lot more, but that's basically it for Ludus for now.
|
||||||
|
`monitor/1` makes it easy to write an `await`.
|
||||||
|
|
||||||
|
As I'm thinking about this, I actually want to roll back `spawn` as a special form.
|
||||||
|
I think it's actually a good cognitive shift to understand that functions are reified, deferred computations.
|
||||||
|
And that processes take this a long way.
|
||||||
|
We can revisit the idea of a special spawn form later.
|
||||||
|
|
|
@ -76,7 +76,7 @@ pub fn lexer(
|
||||||
"nil" => Token::Nil,
|
"nil" => Token::Nil,
|
||||||
// todo: hard code these as type constructors
|
// todo: hard code these as type constructors
|
||||||
"as" | "box" | "do" | "else" | "fn" | "if" | "let" | "loop" | "match" | "panic!"
|
"as" | "box" | "do" | "else" | "fn" | "if" | "let" | "loop" | "match" | "panic!"
|
||||||
| "recur" | "repeat" | "then" | "when" | "with" | "or" | "and" | "receive" | "spawn!" => {
|
| "recur" | "repeat" | "then" | "when" | "with" | "or" | "and" | "receive" => {
|
||||||
Token::Reserved(word)
|
Token::Reserved(word)
|
||||||
}
|
}
|
||||||
_ => Token::Word(word),
|
_ => Token::Word(word),
|
||||||
|
|
Loading…
Reference in New Issue
Block a user