2025-09-23: AIFPL

Published: 2025-09-23

AIFPL development insights, Claude behavior observations, and architectural improvements

Sometimes circular references are unavoidable

I tend to go to extreme lengths to avoid circular references in code, but AIFPL has demonstrated one of those few places where I end up with one that I can't do much about (if I want to keep my sanity).

The problem is in evaluating functions. Functions need environments but those environments contain functions.

In theory I could break this via some interesting indirections but that risks a lot of performance overheads. I don't like this but I'll live with it for now

Claude losing track of things

Once a file gets to about 2000 lines, Claude seems to start to forget things. I had a good example of this in a refactoring of the AIFPL built-in function logic.

I asked it to break out each built-in function into a separate method (improves readability and maintainability), but this resulted in it forgetting to glue these into the function that applies them. When this caused a test regression it just fixed the cases that triggered test failures and not any others. This does indicate I've got some interesting test coverage gaps though!

What's odd is this only happened in one session. The next session picked things up and worked fine.

Cleaner higher-order and built-in functions

The early implementations of AIFPL did some very strange things to support higher-order and built-in functions. This added a surprising amount of complexity in the implementation and made the code much harder to understand. Reworked this so the code is now much more straightforward.

Adding "quote"

One omission in the original design was the absence of quote. We could build quite complex things with AIFPL, but the lack of quote meant we could not really write code that manipulates code as data.

Adding AIFPL tool tests

Added AIFPL tool tests. When I did this I also moved the code structure around a little to make it easier to work out which code is associated with which tool. Also updated the tests to match the new structure.

Retiring the old calculator tool

The old calculator tool does far less than AIFPL and there's not much point in keeping it. Retired it!