Adding Use Option for Existing Constant

Greetings all. This may seem a bit odd of a thing for me to be playing around with but rather than exposing implementation details like this:

Use DICT_WORD_SIZE of 15.

I was curious if I could do the following (which seems more in the spirit of Inform 7’s don’t expose underlying information if you don’t have to):

Use dictionary word size of at least 15.

To see if that would work, I tried this:

Use dictionary word size of at least 9 translates as (- #IFNDEF DICT_WORD_SIZE; Constant DICT_WORD_SIZE = {N}; #ENDIF; -).

That doesn’t not work (as in " it does compile"), but it also doesn’t do anything.

Now I’m just curious how you would handle something like this. Where “this” means a constant that is already defined as part of how Inform operates, but you want to wrap setting the value for that constant in a use option.

First, this change is already set up in the Inform source, and will be in the next release. The phrasing will be:

Use dictionary resolution of N.

Now your actual question:

The option “Use DICT_WORD_SIZE of 15” doesn’t set an Inform 6 constant. It sets an Inform 6 compiler option. (This is the line !% $DICT_WORD_SIZE=15 at the top of the generated I6 file.)

The compiler uses this to determine the dictionary structure. It then sets the I6 constant DICT_WORD_SIZE to expose this to game code, but that’s secondary. You can’t affect the dictionary structure by resetting the constant.

There’s no tidier way to set these options than the “Use” syntax. In 9.x you could write something like

Include (-!% $DICT_WORD_SIZE=15
-) before "ICL Commands" in "Output.i6t".

But this is hardly an improvement, and in any case 10.x doesn’t support that kind of inclusion any more.

1 Like

Sweet!

And now I better understand the distinction and why what I was attempting wasn’t working. Much thanks for the context and knowledge.

1 Like

no more gender issues for superheroes !!! :smiley:

Best regards from Italy,
dott. Piergiorgio.

1 Like