[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Groff] proposal: add variable traps to groff.
From: |
Klaus Robert Suetterlin |
Subject: |
[Groff] proposal: add variable traps to groff. |
Date: |
Thu, 30 Sep 2004 13:34:41 +0200 |
This is a proposal for a new kind of trap to be added to the groff
engine. Maybe someone with more insight than me could comment on
this.
A variable trap that triggers whenever a variable (register and
string, maybe even diversion, environment, macro) is accessed, i.e.
created, deleted, changed, read. The trap macro gets a description
of the variable (register or string) and of the access (action with
data). The trap macro can modify the result of the action and can
have additional side effects.
Example in pseudo code:
.wr R A MACRO [blob]
this installs a trap that triggers whenever register R is accessed
by an action encoded in flag A (1:test, 2:read, 4:write, 8:delete,
or a sum of these). blob is a way to give arbitrary data to the
trap (most likely a name, that must be interpreted by the MACRO)
When the register is read or tested for existance the trap calls
MACRO _before_ the result is calculated:
.MACRO [blob] A R
When it is written or deleted the MACRO is called _afterwards_:
.MACRO [blob] A R [O]
where O is optionally the old value when it existed.
.wr .p 4 recalculate-traps\" Make sure traps are ok when page length changes
.wr my-magic-variable 12 restore-old\" Variable cannot be changed or deleted
.de retsore-old
. if d \\$2 .if \\$1>3 .nr \\$1 \\$3
..
To delete such a trap just state
.wr R A
and the traps for all specified actions get deleted.
The same could be done for strings with a .ws request. Or a more
general variable trap .wv that that takes an additional type flag
that specifies the type of variable (register, string, ...) to be
watched.
Regards, Robert S.
- [Groff] proposal: add variable traps to groff.,
Klaus Robert Suetterlin <=