There have been a couple of suggestions on IRC that the interface design of wmllint should change. Specifically, it has been suggested that:
(1) WML files should be version-stamped, and/or (2) wmllint transformations should be explicitly invoked by command-line switches. I will now explain why I think both proposals are mistaken. First, by way of explanatory analogy, a brief foray into graphics formats and what PNG taught me. When I first encountered PNG back in the 1990s, I wad a little disturbed that it has no version number in its header. "What", I asked myself "do you do when the format changes? Are old readers screwed?" It took me some study to understand what the PNG designers had done. PNG is written as a series of chunks. Each chunk is in the same packet format and has a chunk ID. To change the format, you add a new chunk type in the same format as the existing ones, and possibly stop generating one or more of the old chunk types. As long as the packet format itself is stable, old readers cope as well as is possible because (by design) they ignore chunk types they don't know how to process. (Maybe they throw a warning.) Studying this design persuaded me that file format version numbers are a bad thing for at least two reasons. (1) They're not fine-grained enough. They tell you something (possibly something incompatible) has changed, but they don't tell you *what*. (2) When a version number gets out of sync with the reality it's describing, hilarity ensues. PNG neatly avoids even the possibility of this happening -- you never look at a version number, you run through the file's chunk structure and look at the truth. There are still good use cases for version numbering. Sometimes it's not possible to use a strategy like PNG's with neatly self-describing content. *But WML is not one of these cases*. WML syntax, like PNG's packet structure, guarantees that a WML file will be parseable even if it has unknown tags and/or attributes in it. This is why I think an explicit version stamp in WML would be a mistake. Better for parsers (and wmllint) to do as PNG does; rely on the low-level syntactic regularity of the format, look at the truth, and throw an exception if the truth includes tags you don't recognize. A version number would just be a distraction. It would violate what database designers call the SPOT ("Single Point of Truth") rule, sometimes known in coding circles as the DRY (Don't Repeat Yourself) rule. Now, about invoking transformations explicitly... I wrote wmllint, so I know that the set of transformations in it has the following property: *no transformation ever produces on output a text pattern that is any of the other transformations' inputs*. I'll call this the "no-transitive-chains" propety, or NTC for short. Because NTC is true, the --oldversion option is currently useless. (I included it as a hedge against NTC ever being violated.) You just run wmllint on any WML back to the beginning of time and it updates the WML to the current version. Among other things, this means (in principle) that you could embed wmllint in the campaigns server and have it automatically lift submitted UMC. As long as NTC is true, there would be no point in invoking wmllint transformations separately. And what you can't invoke separately, *you can't get wrong*. Adaptive code that automatically preserves the invariants you care about is better than switches that can break things. So. The effort that would go into choosing and implementing transformation switches would be better spent ensuring that NTC is never violated. This has implications in at least three areas: 1. We have to be fairly careful about reusing resource file names. 2. We have to be equally careful about reusing WML tag names with different enclosed or enclosing tags. 3. When Mordante's map-border stuff gets done, we'll need in the final design an unambiguous way for wmllint to know if a map already has a border. For example, the syntax transformation boucman has requested in FR #9952 could violate NTC by the way it changes the use of the [animation] tag. The new block will probably have to be called [effect_anim] or something else, otherwise I think this transformation could trigger on its own output. Up to now the NTC invariant has been maintained in my head. I think there is at least one thing that could be done to check it; wmllint can look for NTC violations in its tables for resource-file renaming at its startup time. I'll look into coding that. -- <a href="http://www.catb.org/~esr/">Eric S. Raymond</a> When only cops have guns, it's called a "police state". -- Claire Wolfe, "101 Things To Do Until The Revolution" _______________________________________________ Wesnoth-dev mailing list Wesnoth-dev@gna.org https://mail.gna.org/listinfo/wesnoth-dev