Ludus should allow spawn!ing turtles #56

Closed
opened 2025-07-02 16:21:34 +00:00 by scott · 2 comments
Owner

Let's do multiple turtles!

The core turtle graphics functions, forward!, etc., address :turtle_0.

We need to design and devise an API for additional turtles.

I think what we want to be able to do is something like the following:

let myturtle = spawn_turtle()
myturtle ::forward! (100)

This depends upon method sugar, but hey, that's fine.

The one issue I have with this is that, conceptually, forward! (100) isn't just sugar for myturtle ::forward! (100); that means that you can't do send (:turtle_0, (:forward!, 100)).

Architecturally, I can't do this now, since prelude is loaded synchronously before every run, and can't spawn actors it can pass to processes.

For now, I think that's okay. I don't want to muck with the architecture at this point. Long-term, we will probably want some architectural flexibility around this.

Let's do multiple turtles! The core turtle graphics functions, `forward!`, etc., address `:turtle_0`. We need to design and devise an API for additional turtles. I think what we want to be able to do is something like the following: ``` let myturtle = spawn_turtle() myturtle ::forward! (100) ``` This depends upon method sugar, but hey, that's fine. The one issue I have with this is that, conceptually, `forward! (100)` isn't just sugar for `myturtle ::forward! (100)`; that means that you can't do `send (:turtle_0, (:forward!, 100))`. Architecturally, I can't do this now, since `prelude` is loaded synchronously before every run, and can't spawn actors it can pass to processes. For now, I think that's okay. I don't want to muck with the architecture at this point. Long-term, we will probably want some architectural flexibility around this.
scott added the
feature
label 2025-07-02 16:21:34 +00:00
scott added this to the Core: CC2 milestone 2025-07-02 17:15:25 +00:00
Author
Owner

In fact, it's the case that we need actors to do this, but we're going to use actors to do this. It would be easy enough for turtle functions to take a keyword turtle id--if we're keeping track of multiple turtle states in a single boxed dict, then there's no reason we couldn't do this.

Of course, we do want actors to do this. Anyway, this should work now. But we have a few other things we have to do to the language to make this ergonomic.

In fact, it's the case that we need actors to do this, but we're going to use actors to do this. It would be easy enough for turtle functions to take a keyword turtle id--if we're keeping track of multiple turtle states in a single boxed dict, then there's no reason we couldn't do this. Of course, we do want actors to do this. Anyway, this should work now. But we have a few other things we have to do to the language to make this ergonomic.
Author
Owner

Done in 8e75713cd7

Done in https://alea.ludus.dev/twc/rudus/commit/8e75713cd7aae816716cb810e6b8ba0adf6fd301
scott closed this issue 2025-07-06 02:34:51 +00:00
Sign in to join this conversation.
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: twc/ludus#56
No description provided.