Each before/instead/after are being consulted with each and every action. This was debated in this thread and various other places.
before/instead/after can be used on non-specific actions:
Before doing something other than examining or approaching to something which is not within the location:
However, they are mostly used on specific actions:
Before going through the Pearly Gates:
Before going a squared-off direction:
Before going through a closed door (called the blocking door):
So maybe Inform should only consult âBefore goingâ when an actor is going - and not with each and every action - the same way that âcheck goingâ works.
Would this be a moderately easy hack, or is it one of those things that just isnât worth it?
As far as I can tell, this would require rewriting parts of the I7 -> I6 translator to have it make separate rulebooks for each action. Right now, the behavior of Before is the same as any other I7 rulebook; âcheck goingâ is a single rulebook all its own, as is âcheck eatingâ and âcheck jumpingâ and so on.
The ability to write a âbeforeâ rule for multiple actions is pretty important.
Although, really, it should be possible to write a âcheckâ rule for multiple actions. The current system is an awkward compromise between expressivity and efficiency.
So âbefore goingâ will be invoked with every action, even though it obviously is linked to a specific action (going).
Likewise âCheck doing somethingâ wonât work, because check only works with specific actions.
I was thinking, maybe there is some practical reason for the rules to be seperated into those that only work for specific action, and those that work for all actions?
âSpecific actionâ ones are a bit more efficient, since they avoid the small overhead of a function call and return when they arenât needed. But they donât let you handle the fairly common use case of one rule affecting multiple actions.
Ideally the compiler could do that optimization for us, placing rules which apply to only one action in a specific rulebook. But it would be a lot of back-end work for not much improvement; it might be more effective to e.g. hand-tune the indexed text code further, or find some way to mechanically optimize expensive âevery turnâ rules.
But sometimes authors will want a Before going rule that runs in between two multi-action Before rules, so they all have to be in the same rulebook anyway.
The compiler cannot optimize about what rules are in what rulebooks, for that reason. It can optimize how it generates rulebook functions. For example, it could use a switch statement rather than a chain of ifs where thatâs appropriate.
(However, this runs into the problem that an I6 switch statement is a chain of ifs, so that wouldnât actually save any time.)
Perhaps I missed this upthread, but is it because âInsteadâ âBeforeâ and âAfterâ are their own gigantic single rulebooks, and something like âCheck taking the candlestickâ is a more specific âcheck takingâ rulebook?
So you can âInstead of unmaidenly behaviorâ but you canât âcheck unmaidenly behaviorâ.