<https://github.com/nim-lang/Nim/pull/21066> changed the definition (and 
implementation) of what a "strict function" is once again. The definition was 
changed to "stores to locations that involve a ptr/ref indirection are 
forbidden". As you can see in this pull request this makes the language less 
expressive and requires more `.cast(noSideEffect)` overrides but in practice 
the number of required changes was quite low.

The advantage is that rule is much easier to teach and reason about. Reporting 
an error only has a single line information. Complexities like "X is the 
statement that potentially connects Y to a graph G that is connected to an 
immutable parameter P and Y is mutated here" are gone.

Another benefit is this new language rule does not depend on alias analysis so 
that generic code is not affected. No more "my generic func works with int but 
not with ref T".

It's now so simple that I think we can enable strict funcs in upcoming Nim 
versions and eventually reap the benefits for Nim's optimizer. But as usual, 
the optimizer can also compute the same property on its own and not bother Nim 
programmers.

Reply via email to