
I’ve used Places to do multi-threading

It’s kind of a pain, because I often use parameters to set global variables, and you need to have a kind of “setup” phase where you send all of your global variables to all of the new places

But on the other hand, it is very safe and there aren’t any threading bugs, which is a joy

It feels a lot like using “multiprocessing” in Python

The second biggest frustration has been that Places is designed for distribution as well as multiprocessing, which means only serializable data can be sent across the channels. That limitation is frustrating in a single address space

But while this constrains the initial design, it isn’t much of a problem moving forward

Oh, there’s another frustration due to its implementation with a quasi-separate-process implementation: you can’t write a parallel-for implementation as a function, because once you spawn the child threads you can’t send them a function to run, and they can’t access that function from lexical scope.

In Cassius I have a parallel-for macro (for/threads
in src/report.rkt
) but even then it’s project-specific since it has to send over parameter values

Hmm, also there’s some annoyance with sync
: when you sync
over a list of thread channels, you aren’t told which thread sent the message you receive, so you can’t send it new work. I use a weird protocol where the manager thread sends each worker the other end of its channel, and the worker sends “itself” back to the manager when it’s done with its work.

That took a while to figure out but is basically good now.

Say, I want to create struct definitions to represent syntax object. It seems there are two ways I can do it. One is to make struct definitions completely independent, and then have (define my-syntax? (disjoin …..)). Another is creating a dummy struct named my-syntax, and have every syntax struct inherits it. Which one is more idiomatic?

@sorawee I think the latter is more idiomatic to most racketeers but I personally prefer the former, because I find it easier to just outright ban subtyping