Skip to content

Instantly share code, notes, and snippets.

@ELLIOTTCABLE
Last active August 29, 2015 14:20
Show Gist options
  • Save ELLIOTTCABLE/6b6dc416a99785e7d605 to your computer and use it in GitHub Desktop.
Save ELLIOTTCABLE/6b6dc416a99785e7d605 to your computer and use it in GitHub Desktop.

Cascading responsibility

At the moment, more than one Exec can be responsible for a given Thing. This is bad:

  • Responsibility represents the ability to sequentially read from a data-structure without interruption, or modify a data-structure without interrupting somebody else's sequential-read.
  • Given-responsibility thus represents blessing another modifier (or reader) by saying “their process is a sub-step in my own process,” or, effectively, “I expect them to modify the thing I've said not to modify.”
  • Currently, however, this doesn't protect at all against you, and your subjects, from interleaving in unintended ways: just because you want to give a step exclusive permission to complete without giving up your ability to exclude other processes permission, doesn't mean you want that sub step's permission to supersede your own, unexpectedly, later on.

Thus, I need to modify the boolean ‘responsibility’ system to be dimensional: that is, encode the cascading nature of responsibility in a way that can be tracked, and stratify it with rules about how cascading is allowed to proceed:

  • ‘Granting’ responsibility to a sub-step you expect to preform some work should function identically to discarding responsibility (in that you, yourself, lose apparent responsibility for the object in question; and can again request it as normal.)
  • Unlike normally discarding responsibility, however, this operation does not allow any unrelated operations waiting on responsibility to proceed: it's an atomic operation that directly prepares the delegate to acquire responsibility.
  • Relatedly, the releasing of responsibility by a delegate preforms differently from ...

Note: It is important that this set of operations be indistinguishable from within the delegated step: the ‘asking for responsibility of the data we intend to mutate’ step is the same from within that step, regardless of whether the caller already had responsibility (and delegated it); or the caller was completely unaware. (This is important, because this means that the caller doesn't need knowledge of whether the child mutates/reads, unless the caller itself mutates/reads. We don't want the child to need to demand that any caller take, and then grant, responsibility.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment