hhvm
hhvm copied to clipboard
Add <<__DoNotCallTwice>> attribute or similar
eg shortcut for this pattern:
static $called = false;
invariant($called === false, __FUNCTION__.' should not be called twice');
$called = true;
I'm not convinced that this is a common enough pattern to be worth the effort? Could be wrong though. Also while the runtime semantics are clear, I'm not totally sure if the typechecker could enforce it, or how.
How would this interact with coeffects? Would methods with this attribute require write_props
? Would functions require write_globals
?
I'd be surprised if a pure function would throw if the inputs were unchanging between one invocation to the next.