Caterpillar

Daily Thought - 2024-11-26

< back to list

Before I continue my musings on rewinding, here's a quick update on the latest developments: I aborted my attempt to implement a fully inferred static type system. My hypothesis, that this won't be that hard for a very basic type system, was clearly false. In fact, it seems that type inference requires a minimum threshold of type system complexity.

One problem is that concrete types can not always be inferred locally, within a function. Instead, you can infer the most general type that would work there, and later check that any arguments supplied to that function meet those requirements. What I'm describing here are basically generics, or some complex thing in the inference algorithm that works around the lack of generics.

And there are other hurdles too. For example, if you have a function that never returns, it doesn't really matter which return type you annotate it with. But with inference, you have to detect this case, and need to be able to represent it in the type system (that's usually called the "empty" or "never" type). I've decided that at this point, all of that is not worth the trouble.

<< previous thoughtnext thought >>