emdash / udlang

A practical, functional language for stream processing.
GNU Lesser General Public License v3.0
1 stars 0 forks source link

Concept: Signals -- a simple mechanism for communcating with the environment #18

Open emdash opened 3 years ago

emdash commented 3 years ago

The idea: a fixed set of stateless blocks that get run in response to lifecycle events.

import my_lib;

resource resource1: my_lib.Resource(id, "path/to/some/large/image.png");
resource resource2: my_lib.Resource(id, "path/to/some/complex/image.svg");
resource resource3: my_lib.Resource(id, "path/to/some/complex/image.svg");

when load {
   reset();
   resource1.load();
   resource2.load();
   // oops we forgot to load resource3
   // how do we handle this?
};

when exit {
   resource1.drop();
   // oops we for got to resource2.drop();
   // how do we handle this?
};

when error (err)  {
  my_lib.panic("Houston, we have a problem", err)
};

Questions: