I know, I know — most IF authors could care less about Inform 6. But this is kind of cool, so I thought I’d share it with anyone who actually does still use I6. You can create local arrays of routines, like this:
routine_array [; "Fred!"; ] [; "Wilma!"; ] [; "Barney!"; ] [; "Betty!"; ],
You’ll note that there are no commas after the routines, until the end (when presumably you’re about to declare another property), and they have no individual names. Having set it up this way, you can access the elements of the array like this:
y = some_object.&routine_array-->x; y();
This is potentially useful because it lets you encapsulate different kinds of behavior and then switch among them at run-time. You could do the same thing with a switch statement, but this way of doing it is likely to be easier to read and debug than a massive block of code in a switch. Fewer indents, if nothing else.
Since I6 doesn’t force the elements of arrays to be of a single type, you can also build property lists like this that contain routines, double-quoted strings, and object IDs. You then use:
if (y ofclass Routine) y(); else if (y ofclass String) print_ret (string) y;
…and so on, in order to use the elements in the array.