A modular replacement for adv3's executeCommand()

I think my modular replacement for executeCommand() is working. Github repo for modularExecuteCommand.

It should be a drop-in replacement for executeCommand(). It works by modifying PendingCommandToks.executePending() to use a method on the new modularExecuteCommand singleton instead of adv3’s builtin executeCommand() function (which is untouched).

There’s no particular reason why you’d need this if you weren’t looking to fiddle around with the command execution cycle. But if you are, the intent is to make it easier to twiddle individual bits (like doing a modify modularExecuteCommand to replace a single method) without having to replace the entire hundreds-of-lines-long executeCommand().

In addition to being able to replace/modify individual steps of the process, the module implements “standalone” exception handlers for the inner loop. In the stock executeCommand() there’s a try block followed by a sequence of hardcoded catch() handlers. The module has a single try/catch block, and implements a ModularExceptionHandler class. You can define instances of ModularExceptionHandler and they’re automagically be used for any matching exceptions thrown during processing. E.g., the replacement for the stock ParseFailureException catch() block looks like:

mehParseFailure: ModularExceptionHandler
        type = ParseFailureException
        handle(rfExc) {
                rfExc.notifyActor(execState.dstActor, execState.srcActor);

The type determines what kind of exception it handles, and the handle() method does the handling, its arg being the exception object thrown during processing.

Anyway, like I said this is something that most people won’t have any use for, but I’m putting it out there anyway. I’m in the process of refactoring the noun-as-verb stuff (where all of this originated) to use the new executeCommand() replacement.


I’d be interested if I hadn’t already rewritten my executrCommand long ago…

I was interested in a more modular version mostly because I’d re-written executeCommand()…and then I had to do it again.

1 Like