Nim is a compiled, garbage-collected systems programming language with a design that focuses on efficiency, expressiveness, and elegance (in that order of priority).
add a read-only mutations: int field to containers like Tables, StringTableRef, to indicate the number of mutations that occurred in the container, and an accessor proc mutations*(self: Container): int to access it; the field simply gets incremented on each mutation (eg: Table.[]=)
proposal
add a read-only
mutations: int
field to containers like Tables, StringTableRef, to indicate the number of mutations that occurred in the container, and an accessorproc mutations*(self: Container): int
to access it; the field simply gets incremented on each mutation (eg:Table.[]=
)example use case 1:
would simplify things like https://github.com/nim-lang/Nim/pull/18244 => allows caching a value and knowing how long you can hold on to it
example use case 2:
solve https://github.com/nim-lang/Nim/pull/18260 in a robust way, preventing mutating a table during iteration, instead of the following weaker test:
example use case 3:
allows user to tell whether a key help by pointer (eg via
gePtr
(https://github.com/nim-lang/Nim/pull/18253) or mitems.addr) is still valid at some later point