2005-06-19 · in Ideas · 113 words

This is "die or run forever"; the idea is that we wish to run a "daemon" process which might fail to start. We do this by having a flag variable which is tested on startup; if the flag is FALSE, then we try to start and set the flag depending on whether we succeed, else we just immediately return. For example, audio output code for a synthesiser:

PAR
  INITIAL BOOL ok IS FALSE:
  SEQ
    alsa.output (..., ok)
    oss.output (..., ok)
    IF NOT ok
      die ("No sound device available.")

This tries ALSA first, then OSS, then otherwise dies. When we terminate the sound driver, we just need to make sure that it sets ok to TRUE.