johnynek / bosatsu

A python-ish pure and total functional programming language
Apache License 2.0
222 stars 11 forks source link

add a todo function when running type check #1173

Open johnynek opened 3 months ago

johnynek commented 3 months ago

when working on #1171 I found a pattern which was useful:

external def todo(ignore: x) -> forall a. a

this function can consume arguments to make them look used, and then return anything. Of course, you can't have a function like that at runtime.

On way to avoid that is to only add that function to predef when in type-check mode. In that case, we never even emit anything, any so it can't be unsafe. This could also be used by a language server in the IDE, since you don't need the compiled outputs in that case either.

If we had a resident server that could cache memory, we could keep a cache of compiled packages for dependencies but only use it for type-checking (or rather, the cache key can depend on if we are in type check mode or not).