ta0kira / zeolite

Zeolite is a statically-typed, general-purpose programming language.
Apache License 2.0
18 stars 0 forks source link

Fix persistent, unbounded cache size for recursive param substitution. #97

Closed ta0kira closed 3 years ago

ta0kira commented 4 years ago

This is a follow-up to https://github.com/ta0kira/zeolite/issues/48#issue-613657916.

ta0kira commented 3 years ago

It wouldn't be unreasonable to have a hard limit on param nesting, although that wouldn't help in cases of exponential expansion.

@type killEverything<#x,#y> () -> ()
killEverything () {
  \ killEverything<Type1<#x,#y>,Type2<#y,#x>>()
}

On the other hand, such code doesn't need cached TypeInstance to cause major problems. Is there even a practical situation where you'd need arbitrary recursive substitution that couldn't just be done with values?

I guess the real risk is that the compiler might allow someone to do this when they intended to do something else. If the same structure was used for values instead of types, the user would get a massive object in memory, but it would later get deallocated.

Overall, I don't think this is a major risk. I'll reopen this if I come across a situation where it's easy to cause major problems. As long as type instances can't have persistent data, it should always be possible to just skip caching type instances altogether or have an aggressive cleanup policy.