Caterpillar

Daily Thought - 2024-11-08

< back to list

So, I need to track the arity of every expression at compile-time. And doing so is complicated, because of the eval intrinsic, which has an arity that depends on the anonymous function it evaluates. I came across this problem maybe a week or so ago (or was it 2, maybe 3? I can no longer tell 😂).

The core problem here is, that the eval call not only needs to work where the anonymous function is defined. You can also return the anonymous function from where it was created, and then evaluate it elsewhere. If all you do is track arity, you'll lose the information that you need to assign an arity to the eval call, leaving the system with holes.

So you need to track which of a function's return values is an anonymous function. But since anonymous functions can return other anonymous functions, it's also not enough to just track the arity of those. At this point, I think it becomes easier to forget about arity, properly define what a type is, and track which types every expression consumes and produces. That's a static type system.

<< previous thoughtnext thought >>