I was looking more closely at the PrefaceByArticle()
routine, and I noticed something that looks like a bug going back to at least StdLib 6/11.
There’s a section
artform = LanguageArticles
+ 3*WORDSIZE*LanguageContractionForms*(short_name_case + i*LanguageCases);
#Iftrue (LanguageContractionForms == 2);
if (artform-->acode ~= artform-->(acode+3)) findout = true;
#Endif; ! LanguageContractionForms
#Iftrue (LanguageContractionForms == 3);
if (artform-->acode ~= artform-->(acode+3)) findout = true;
if (artform-->(acode+3) ~= artform-->(acode+6)) findout = true;
#Endif; ! LanguageContractionForms
#Iftrue (LanguageContractionForms == 4);
if (artform-->acode ~= artform-->(acode+3)) findout = true;
if (artform-->(acode+3) ~= artform-->(acode+6)) findout = true;
if (artform-->(acode+6) ~= artform-->(acode+9)) findout = true;
#Endif; ! LanguageContractionForms
#Iftrue (LanguageContractionForms > 4);
findout = true;
#Endif; ! LanguageContractionForms
the purpose of which seems to be to compare the “contraction forms” of articles in the LanguageArticles
table for a given article case, and, if a difference is found, set a flag findout
to true. As an example, the LanguageArticles
array looks like this for English:
Array LanguageArticles -->
! Contraction form 0: Contraction form 1:
! Cdef Def Indef Cdef Def Indef
"The " "the " "a " "The " "the " "an " ! Articles 0
"The " "the " "some " "The " "the " "some "; ! Articles 1
Engish has LanguageContractionForms == 2
, so the applicable line for determining the value of the findout
flag would be
if (artform-->acode ~= artform-->(acode+3)) findout = true;
This would compare, say, the first and fourth values of row “Articles 0” ("The "
and "The "
, which are the same), or the third and sixth values of the same row ("a "
and "an "
, which differ).
If findout
is set, then later code will print the relevant portion of the noun phrase to a buffer to determine which of the differing values should apply in this case.
However, the condition (artform-->acode ~= artform-->(acode+3))
can never evaluate to true given the way that Inform 6 stores strings. The two strings "The "
(column 1) and "The "
(column 4) in the first row of LanguageArticles
will have different string addresses even though they have the same text. As a result, findout
is always set to true.
Obviously, it works, but it’s doing more work than it theoretically could in many cases, and more work than the code seems to intend. In the absence of a compiler feature to notice identical strings and set them to the same address, the only fix is to use string constants in the LanguageArticles
table. That works but is a little ugly to look at.
Side note: I also noticed that short_name_case
seems to be totally unused. It’s not mentioned in DM4 at all, so presumably it’s a fossil from an earlier iteration of the system.