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:
where can these appear?
can they be in libraries, or is this a problem?
maybe resources can nest an when load and when exit inside their constructor, so that the details are hidden.
bike sheding about syntax. are these keywords?
should they be extendable by embedding applications?
The idea: a fixed set of stateless blocks that get run in response to lifecycle events.
Questions:
when load
andwhen exit
inside their constructor, so that the details are hidden.