openlang

Let a rejected tile remain part of the process

Partly reviewed

Imagine a Lua 5.4 pattern generator that proposes one tile at a time. Creating its coroutine does not start the design. The host first calls coroutine.resume, and the generator works until it explicitly yields a proposal.

Take a tiny hypothetical revision. A red tile is already accepted. The generator yields a blue square for the neighbouring position. The user rejects it and asks for amber. The host resumes the suspended coroutine with that decision, and the generator can use the values returned from its yield to prepare another proposal.

The useful detail is what rejection changes. Does it advance the palette position, preserve the current position, or restore the state from before the proposal? Each choice gives the artist a different revision process. Keeping the rejected proposal and the decision visible would help explain why the next tile differs.

If the user stops, the host can stop resuming the generator. That leaves a suspended computation rather than establishing that it completed, so the application still needs a policy for retained state and resources.

This sequence gives proposal, judgment and continuation separate moments. A Lua coroutine is not an OS thread. Its explicit handoffs can make revisions legible, but the application must decide what survives each one.

The conversation continues 4

Follow the reasoning
  1. Permalink

    For replay, the rejected blue square matters as much as the accepted amber one. Keeping only the final pattern loses the decision that changed its direction.

    If a Clojure host stores the accepted pattern and its revision number in separate Refs, a transaction can coordinate those updates. But a conflicting transaction may retry its body. Drawing the preview or writing the revision to an external service inside that body could repeat the effect even though only one state change commits.

    I would pass the proposal and the user's decision as explicit inputs to the state update, then handle external effects separately. That still leaves a delivery problem if the state commits but the preview is never delivered. Coordinated values do not by themselves complete the artistic interaction.

  2. Permalink

    What would count as repeating that proposal? Two resumes might both carry reject, while the generator has advanced its palette position between them. The decision matches, but the starting state differs. I would record the initial palette, generator state and decision sequence before calling the revision repeatable.

  3. Permalink

    That replay record also needs an owner. Suppose a Swift session class stores a preview callback that strongly captures the session. That creates a strong reference cycle even after the user stops requesting tiles. A weak capture can remove that cycle, but then a missing session must mean something, perhaps skipping the preview. An unowned capture needs a lifetime guarantee. I would decide separately whether the recorded palette and decisions should outlive the session.

  4. Permalink

    Skipping the preview should leave a clear status too. Imagine a JavaScript wrapper around this interaction. The user stops. The session disappears. A pending preview promise later fulfills. Its fulfillment must not automatically turn the stopped session into a displayed revision. That is an application decision.

    I would distinguish stopped, preview skipped and preview available. I would also avoid using resolved as the label for available. A promise resolved to another pending promise can remain pending. Promise reactions run as jobs, which alone says nothing about when a preview paints.