[I6] Directive like Replace but for constants instead of routines?

I think the title says it all for this one. Does I6 allow constant values in the Standard Library to be replaced somehow, or is it necessary to create a modified version of a given library file to alter a constant found within it?

How about this?

Constant SOME_CONSTANT 42;

You can also wrap the whole thing in an Ifdef if you want, but Undef is specifically defined to do nothing if the value isn’t defined in the first place, so it’s not necessary.

(This being the equivalent, of course, of the C preprocessor’s #undef, because these I6 directives are modelled after the C preprocessor. You can even put a # in front of the directives and change the case if you want to make them look more C-like.)

If you do this, the constant will have different values before and after the redefinition.

This is different from the Replace directive, which takes care that the function behaves the same no matter where you call it in your code.

1 Like

@Draconis, thank you for the pointer to #undef; I didn’t know that it existed. And thank you, @zarf, for the details on how it functions.

I should have mentioned, however, that I’m using Inform 6.31. If I’m not mistaken, I believe that #undef is something that was introduced circa Inform 6.33 (as mentioned in the post at Upcoming additions to the Inform 6 compiler). Is there any functionality comparable to #undef for Inform 6.31?

DM4 implies (as do the comments in english.h) that it’s required to write a new language file and compile with switch +language_name="<modified file>".

Getting back to this – the slightly snarky answer is that if 6.31 had had a way to do #undef, we wouldn’t have added it in 6.33.

The overview of what’s been added to the Inform compiler and language is at https://github.com/DavidKinder/Inform6/blob/master/ReleaseNotes.html (chronological) or http://inform-fiction.org/manual/I6-Addendum.html (categorized).

Have you looked at how the existing language files (http://ifarchive.org/indexes/if-archive/infocom/compilers/inform6/library/translations/) are constructed? They don’t use #undef, obviously.

@zarf, fair enough. It’s not unheard of for languages to be changed as a matter of convenience rather than capability, and it often seems in I6 and I7 that there are possibilities beyond what’s immediately obvious. Snark aside, though, I see your point, and I appreciate the links to additional information. Thank you, once again, for the guidance.