showme vs showobj

Most* Inform 7 globals are stored in a single huge I6 array, so that’s not a problem.

*well, any that have to be accessed by hand-written I6 code are given I6 registers instead, but they’re the minority: things like “noun” and “second”.

A bigger problem might be tables, which are just big blocks of memory, but you can avoid storing data in those if you try hard.

Unfortunately the SHOWME command’s code is created by the ni compiler, which is closed-source so we can’t access the internals. The I6 code in Tests.i6t (which defines all the debugging verbs) looks like this:

[ ShowMeSub t_0 na; t_0 = noun; if (noun == nothing) noun = real_location; if (ShowMeRecursively(noun, 0, (noun == real_location))) { if (noun == real_location) print "* denotes things which are not in scope^"; } if (t_0 ofclass K2_thing) { print "location:"; ShowRLocation(noun, true); print "^"; } {-call:PL::Showme::compile_SHOWME_details} ];

In other words, a nice readable Inform 6 subroutine…with {-call:PL::Showme::compile_SHOWME_details} replacing all the interesting bits. This instructs NI to call an internal routine called “compile_SHOWME_details” that makes all the magic happen depending on the exact details of the game.

On the other hand, you might not need the showme code at all! After all, the fanciest thing it does is figure out the name and type of each property—but a save/restore system doesn’t need that. Just iterate over all objects, iterate over all property numbers, if the object provides that property, save its value as an integer. Whether those bytes represent an int, a float, a pointer, etc is all irrelevant to saving and restoring it: you’ve just got to put those same bytes back in the same spot.

1 Like