Diary 2018-10-03

By Max Woerner Chase

I'm mostly messing around in Prolog right now. I'm implementing super-basic types inside the predicate system, in pretty much the exact way I'm pretty sure I'm not supposed to for any serious code. Doing this leads to all sorts of infinite-loop-blow-the-stack failure modes. I think to deal with those, I need to start differentiating between "predicates that confirm and possibly desugar data" and "predicates that match in a specific progression". If I can write more of the latter, and start them off in the various clauses I've written, that should give it more well-behaved semantics for progression along free variables. This seems like an extremely "procedural" angle to take on the details, but it should allow me to construct higher-level predicates that "just work" in a variety of configurations.

This did give me an interesting thought. One objection I've seen raised to writing code in tail-call or continuation-passing style is that the onus shouldn't be on the humans writing and maintaining code to express its high-level code in a particular way to take advantage performance optimizations provided by the compiler or run-time, if the required style is "unnatural". I'm not going to talk about what's "natural", because my only real anecdote there is being traumatized by a WYSIWYG interface in college. But, supposing we have particular criteria for what's natural, and compilation/interpretation facilities to transform "natural" code to "efficient" form, possibly with some kind of metadata constraints to request particular optimizations and complain when they're not possible. Given all of that, it might be interesting to be able to say "let me call the tail-recursive function this loop body got translated into" or something like that.

What else has been happening lately... I'm pretty tired, which is why I decided to take a break from projects this week. Encoding arbitrary-length two's complement arithmetic in Prolog is for fun.

I got the fourth edition of Calendrical Caluculations as an e-book, which I'm kind of regretting now. The Kindle edition is full of distracting errors. I've reported enough that I feel like Amazon should be paying me for it.