I had been thinking that the tags would be global variables; extensions would include lines like these:
Keycodes hyperlink tag is initially 1.
Command replacement hyperlink tag is initially 2.
Choice nodes hyperlink tag is initially 10.
If the community doesn’t coordinate well, or two people publish extensions at the same time that use the same code, authors would be able to change those values manually.
So, your idea of registering an extension… I actually like that more. However I still like the idea of global variables, because an extension like Choice Nodes would need to know what its tag is in order to create its hyperlinks. It could look up the table for its associated rule, but that’s messy. Instead, what if each extension requested its tag like this:
After starting the virtual machine (this is the register choice nodes rule):
now choice nodes hyperlink tag is the next available hyperlink tag;
A To decide what number is the next available hyperlink tag:
phrase would keep a counter, returning and incrementing the counter. If someone has too many registered tags then it would display a runtime error.
So now that Choice Nodes has registered itself, it can use its tag in the hyperlink handling rules and phrases to create hyperlinks:
A glulx input handling rules for a hyperlink-event (this is the handle choice nodes events rule):
if the current hyperlink matches choice nodes hyperlink tag:
let new node be the hyperlink payload as an object;
...
To say choice (C - a choice node):
set hyperlink with tag choice nodes hyperlink tag and payload C;
The framework extension would provide a few phrases like current hyperlink matches (T - a number)
, hyperlink payload as an object
, hyperlink payload as a signed number
, set hyperlink with tag (T - a number) and payload (P - a value)
. These phrases would handle all the bitshifts, bitmasks, etc, and could even make it so that if anyone did need more than 24bits of payload we could make 25 or 26bits be a compile-time use option without needing any other extensions to be modified. The number of bits for tags could also be a use option.
(BTW, tables use much less memory than lists. Lists use the Flex system so there’s a lot of overhead.)