Thanks. I appreciate that. It's not the worst program I ever wrote, but it's much less good than its replacement will be if I ever finish it.
That's what I decided to do with HotkeyNet. I designed an entirely new language (implemented in HotkeyNet 2) to replace the old one.
http://www.hotkeynet.com/hkn2/ref/LanguageOverview.html
http://www.hotkeynet.com/hkn2/ref/Functions.html
http://www.hotkeynet.com/hkn2/ref/Types.html
Let me give you an example of the bad decisions I made when I designed HotkeyNet's language. The worst one was not having any end-of-block markers. It makes the language terribly confusing. The language *does* have blocks, and they *do* nest, but since there are no end-markers, the language imposes the block structure according to precedence rules which are described under "Blocks and nesting" in the instruction section of the website. I thought this would be simpler than requiring the user to mark blocks, but in fact it makes things harder because the user has to understand the precedence rules.
I did this as an experiment because I had never seen a language with this kind of design, and I was curious to see how it would work. Well, it works very badly! Now I know why nobody designs languages this way!
This is a good example of how a language's syntax can create confusionI don't know if I got a bad example script or if something has changed in HotkeyNet since this was written, but the <PassThrough> in the SendMasterAndSlave template throws the following error:
I'll explain the whole thing from the language designer's perspective, and you can decide if this was one of my mistakes.
What does PassThrough really do? It tells the keyboard hook not to swallow the trigger event. Therefore it's a directive to the keyboard hook.
Every other keyword you write in a defintion (including If) gets executed by the interpreter after the hook finishes. PassThrough is a different kind of keyword. It's the only directive in the entire script language that gets executed by the hook.
The hook finishes before the interpreter begins. Therefore, PassThrough must execute before everything else you write in a hotkey definition.
In particular, PassThrough must get executed by the hook before the interpreter evalutes If.
Originally I thought users wouldn't have to understand this. I thought I could hide these facts from them and make things simpler. But during HotkeyNet's beta test it turned out that PassThrough was a major source of confusion.
So I made a small change to the script language to try to convey the idea to people that PassThrough always executes earlier than everything else.
I added a syntax rule -- which is enforced by the parser -- that requires PassThrough, if it's used at all, to be the first statement in a definition.
I thought this was a clever solution to the problem because everybody assumes scripts execute from top to bottom, and the parser would automatically force them to realize that PassThrough executes first. They wouldn't have to read this in the documentation. The parser would force them to do it correctly by means of an error message.
But as you can see from your own experience, this didn't work. You thought you encountered some sort of problem. Perhaps it would have been better if I had made a completely different syntax for PassThrough.
Connect With Us