User:Furey/References to source code

From NetHackWiki
< User:Furey
Revision as of 02:59, 22 June 2024 by Furey (talk | contribs) (first draft.)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

References to source code

Timeline

2003: NetHack 3.4.3 released.

2005: NetHackWiki created.

2015: NetHack 3.6.0 released.

During the time between 2005 and 2015, there was one vanilla source code, plus SLASH'EM 0.0.7E7F2 source code, plus an abortive attempt at SLASH'EM 0.0.7E7F3 source code (only 5 files were uploaded). So there was one source, THE source.

Editors wrote many different features to reference THE source:

These were fine as long as there was only one THE source.

The new multiversion world

After the release of NetHack 3.6.0, things changed. Some of the methods for making source code references grew a new parameter to specify the version. The new parameter had to be optional, and it had to default to NetHack 3.4.3 so that legacy references would continue to work. This scheme relies on editors conscientiously choosing the right source version when referring to source code.

This scheme has not worked.

Case in point: allmain.c

Consider Source:NetHack 3.4.3/src/allmain.c itself. The second sentence of the article reads: To link to a particular line, write [[allmain.c#line123]], for example.

Wrong. allmain.c used to redirect to Source:NetHack 3.4.3/src/allmain.c, but in December 2015, someone changed the redirect to Source:NetHack 3.6.1/src/allmain.c. This was a quiet change, and it broke callers. It also means anyone using allmain.c today has to remember that this is a 3.6.1 file. Is it going to be a 3.7.0 file in 2026? Nobody knows.

Case in point: speed

Consider https://nethackwiki.com/index.php?title=Speed&oldid=171493 , a historical version from right before I fixed it. Here are three references from the article:

  • {{refsrc|allmain.c|137}}
  • {{refsrc|allmain.c|147}}
  • {{refsrc|allmain.c|119}}

When I followed these line numbers, the results were nonsense. The problem is that the unversioned refsrc defaults to NetHack 3.4.3, but the editor who wrote the article provided line numbers from NetHack 3.6.7. This problem is endemic in our articles.

Case in point: Template:monster

Consider titan. The infobox for monster data shows a source code reference of monst.c#line1438. This resolves to NetHack 3.6.1, and in the 3.6.1 version of src/monst.c, line 1438 is 5 lines away from the actual line that defines MON("titan", ...). A five line version skew is not much but it will get a lot worse when NetHack 3.7.0 releases.

Statistics

Some of our templates track unversioned usage. Statistics as of June 21, 2024.

https://nethackwiki.com/index.php?search=unversioned

Page title matches
Category:Pages with unversioned Sourcecode templates
119 members (0 subcategories, 0 files) - 00:19, 27 January 2020
Category:Pages with unversioned Refsrc templates
258 members (0 subcategories, 0 files) - 00:19, 27 January 2020
Category:Pages with unversioned Reffunc templates
85 members (0 subcategories, 0 files) - 00:18, 27 January 2020
Category:Pages with unversioned Function templates
89 members (0 subcategories, 0 files) - 00:17, 27 January 2020