Coding 2020-11-06

By Max Woerner Chase

I started playing around with my rewritten code, and the behavior seems solid. It still desperately needs tests, but I want to couple any testing with more of a rewrite.

Basically, the change I've been doing recently was to rework how my roller functions send messages to the host application. Formerly, when I knew I didn't need input, I was able, and I think this was the right call within that context, to structure the output as a generator, using yields and yield froms to compose different components. The basic concept, which I haven't yet written a host application to take proper advantage of, was to be able to incrementally display new messages as the calculations are completed. I think all of this is a kind of manual, restricted version of how async is implemented in Python.

Now, Mythic will require the ability to prompt the user for input, and process the result. A much earlier form of this code worked by just using the input function directly, but I wanted something that would be more abstract from the standpoint of the business logic. From reading about async, I thought it would be a better fit in terms of idiomatically expressing the behavior of input and output.

When I actually tried it, I liked the result, especially because it allowed me to rewrite some context-manager type code as an actual context manager, rather than a higher-order function. Marginal effort, marginal gain, good prospects for future changes.

One thing that happened as a result of the rewrite was that I wrote an adaptor class that bridges Click and Trio. I want to move that to its own package in the monorepo. I'll do that first.

And now, I sleep.

Good night.