Thread:User talk:Rua/Possible solution for language-specific form-of templates

Hi. Hopefully I'm not opening a can of worms here. I know you objected in the past to adding behind-the-scenes categorization for certain languages in. I was thinking recently of another solution that preserves your desire of having the categories be visible in the template code itself. The idea is that any language-specific template that works like but adds categories would remain as a separate template but be changed to work in a uniform fashion, i.e. it would take parameters exactly like  (minus the initial language code), and the template definition would specify the categories. As an example, might be internally defined something like

The stuff under catlogic is analogous to what's currently in Module:form of/cats and is a simple domain-specific language (DSL), based on Lisp syntax. In this case, it says this: This is (or should be) the same categorization logic that's found in the current definition of, except that both the template definition and invocations become standardized. Then, in time we can work on removing the excess categorizations, after which the language-specific template can easily be converted to.
 * 1) If it has the tag "indef" (or anything equivalent, such as "indefinite") anywhere, add to Category:Bulgarian noun indefinite forms.
 * 2) If it has the tag "def" (or equivalent) anywhere, add to Category:Bulgarian noun definite forms.
 * 3) If it has the tag "voc" (or equivalent) anywhere, add to Category:Bulgarian noun vocative forms.
 * 4) If it has the tag "count" (or equivalent) anywhere, add to Category:Bulgarian noun count forms and Category:Bulgarian noun plural forms.
 * 5) If it has the tag "p" (or equivalent) anywhere, add to Category:Bulgarian noun plural forms.

It's true that this will require parsing the DSL each invocation, but I doubt this will be an issue, as the specifications are fairly short and won't use up much memory (which is the scarce resource now).

An alternative is to have the categorization logic use template calls directly, through the aid of some auxiliary templates (e.g. maybe e.g. for the   function above). The problem with this is that the code becomes ugly and hacky; you effectively have to pass all the parameters to each such invocation, like this:

Furthermore, it's potentially inefficient because each invocation of has to process and normalize all the inflection tags to do the comparison.