Coding 2020-04-08

By Max Woerner Chase

I got a few more tests knocked out easy, and then I hit TestNestedPassByReference. A test that contains the comment "Bloody whitespace", which is a sentiment that I really agree with right now. Investigating the test's history leads to this commit, which involves changes that produce a more pleasant output. Formerly, the test output would include a snippet of whitespace outputted by the top-level function call, as well as an extra newline. Afterwards, it emits neither. I've somehow managed to write code that includes the extra newline, but not the inline whitespace. (Technically, the inline whitespace is generated, but not rendered.)

Somewhere in the steps of "first line generates newline, execution steps through function, hits next content line, rolls back, outputs line, and steps back through function", something is going wrong.

Okay, I went back to it, because I was just so bothered, and I found the problem. This is pretty much entirely on me; I'll see if I can sum it up quickly.

The C# Ink VM defines boxed versions of various built-in types, including strings. The boxed string includes some pre-calculated common properties, which I foolishly did not port in any capacity, and just tried to do stuff inline where needed. One of these instances is the function TrimWhitespaceFromFunctionEnd, which should have been preventing the whitespace from getting pushed to the output stream in the first place. But there was a problem. In a fit of extreme fanciness, I expressed the isInlineWhitespace property as set(obj.value) == {" ", "\t"}. The correct expression is, obviously in retrospect, set(obj.value) <= {" ", "\t"}. The difference between them is that the original form wouldn't catch strings that only contained one of these characters. Which is most strings we're interested in. The new form does also theoretically drop empty strings, but I'm too tired right now to handle the levels of zen in "does it make a difference to discard the empty string?"

Anyway, I sincerely hope I don't have any more of these tiny oversights on my part to deal with, but that seems unlikely. Technically, I won't have to deal with any of them tonight, because that's enough for now.

Good night.