Up to Main Index Up to Journal for April, 2019 JOURNAL FOR WEDNESDAY 17TH APRIL, 2019 ______________________________________________________________________________ SUBJECT: Full steam ahead! Introducing bound qualifiers DATE: Wed 17 Apr 22:30:58 BST 2019 The launch of the rebuilt site using the new site generator seems to have gone well[1], as promised I am now back hacking away on WolfMUD. Yay \o/ :) First things first, where the heck was I and what was I working on? I had to look back over the journal and my Git history just to remind myself :P I had finished sorting out the recordjar and text folding/unfolding issues. Before that I was working on connection quotas, which I finished. Before that, way back at the start of February, I was working on the new command matcher with the ‘WHICH’ command for testing out some new ideas. What better way to get back into the code than by sorting out some issues and bugs with the new matcher and aliases? In at the deep end, no life jacket and ignoring all the warnings about no swimming allowed. What a rebel! This afternoon I sat down with some fresh coffee and started quietly coding into the evening. What a wonderful time I had. I’m sure I should have been doing something else, if I’d stopped thought about it hard enough. First thing to tackle was the issue of aliases and qualifiers being treated the same. For example if you defined a shortsword with the aliases: Aliases: +SHORT SWORD SHORTSWORD Here we have the qualifier ‘SHORT’ denoted by the leading ‘+’. This means we can use the following commands: WHICH SHORTSWORD WHICH SWORD WHICH SHORT SWORD However we can also use: WHICH SHORT SHORTSWORD WHICH +SHORT Which is undesirable at best. The first change I’ve made is to have attr.Alias treat qualifiers and aliases separately. Now if you call the Alias.HasAlias method it can only search aliases, and not select a qualifier. To search and select on qualifiers there is a new Alias.HasQualifier method. There is also Alias.Qualifiers which returns a string slice of all the qualifiers, just like Alias.Aliases does for aliases. All of this means that the following command will no longer work: WHICH +SHORT Next stop was to sort out the problem of qualifiers being global to all of the aliases available on an item. I have called this feature ‘bound qualifiers’ as it lets you bind a qualifier to a specific alias. This is what it looks like in action: Aliases: +WOODEN +SHORT:SWORD SHORTSWORD I’ve thrown in the qualifier ‘WOODEN’ there as well to help with the examples. Bound qualifiers have the general form ‘+qualifier:alias’. Here we have the bound qualifier ‘SHORT’ which can only be used with the alias ‘SWORD’. For example, all of these commands are valid: WHICH SWORD WHICH SHORT SWORD WHICH WOODEN SHORT SWORD WHICH SHORT WOODEN SWORD WHICH SHORTSWORD WHICH WOODEN SHORTSWORD Because ‘SHORT’ is bound to ‘SWORD’ only, this will not work: WHICH SHORT SHORTSWORD Another thing to notice is that we didn’t specify ‘SWORD’ as an alias. You could add the alias ‘SWORD’ if you wanted to, but the alias for a bound qualifier is added automatically if it doesn’t exist. You can bind multiple qualifiers to the same alias and you can bind the same qualifier to different aliases. Pointless example time: Aliases: +WOODEN:SWORD +WOODEN:SHORTSWORD +SHORT:SWORD Here we bind the qualifier ‘WOODEN’ to the aliases ‘SWORD’ and ‘SHORTSWORD’. We also bind the qualifiers ‘SHORT’ and ‘WOODEN’ to the alias ‘SWORD’. About the only thing you can’t do is bind a qualifier to another qualifier. As I’m not sure exactly how useful bound qualifiers will be in practise, I’ve not worried about binding to other qualifiers[2]. Although bound qualifiers might not be that useful, it was a small change to add the feature once I’d separated aliases and qualifiers. All of this, plus a few minor tweaks, are now out on the public dev branch. Next up will be to convert existing commands to use the new matcher. -- Diddymus [1] There was one little nit with email addresses whcih I've just fixed. [2] I would be very interested if anyone has a practical use for binding a qualifier to another qualifier. Drop me an email with some examples and I’d be happy implement the feature: diddymus@wolfmud.org Up to Main Index Up to Journal for April, 2019