Working with tables and strict funcs

2022-01-19 Thread Hlaaftana
I edited my post to properly answer your question.

Working with tables and strict funcs

2022-01-19 Thread Hlaaftana
Use `var` and `var Foo`. {.experimental: "strictFuncs".} import tables type Foo = ref object data: Table[string, int] func readData(f: var Foo, k: string): int = f.data[k] if isMainModule: var f = Foo(data: initTable[string

Working with tables and strict funcs

2022-01-19 Thread jayv
Yes, that clears the compiler error, but it's actually the opposite of what I want. I want the compiler to see that `f` is immutable, so in a more complicated scenario it can catch any errors where I do mutate it by accident.

Working with tables and strict funcs

2022-01-19 Thread jayv
I like the strict funcs experimental feature, and I like using it in my side projects. But I'm having a small issue and wanted to see what others think about it. Here's the setup: I have a reference type with a private member that is a table. I want a pure function to be able to read from that