Skip to content

Improve Experimental/do-control Terminator Semantics #1742

@Jason94

Description

@Jason94

(Mostly dropping as a note to myself. I'll get around to this soon.)

Currently in do-control-core the semantics of the Terminator class are a little weird. The main method is called ended? which is true for True bools, and then also empty containers (None, etc.)

This leads to some weird code, like this, which makes little sense. Note how continue? has to be False to get the thread to keep going:

  ;; TODO: Flip bool and when_ term semantics
  (declare run-program-1 (IO Unit))
  (define run-program-1
    (do
     (a <- (new-tvar 0))
     (b <- (new-tvar 0))
     (continue? <- (new-mvar False))
     (thread1 <-
       (do-fork-thread_
         (do-loop-do-while (read-mvar continue?)
           (run-tx (increment-int a)))))

It should probably be reworked so that:
(1) False and empty values represent "stop," and True and non-empty values represent "continue"
(2) Existing functions that use the Terminator class should work in the more natural way. (do-when True ...) should execute, (do-loop-do-while True ...) should loop forever, etc.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions