Hi.
I'm trying to clone the "table" code to run (unguarded) on the shared heap, and I noticed something strange; in the tables module, there are procs like this:
proc `[]`*[A, B](t: Table[A, B], key: A): B {.deprecatedGet.}
So we should not use table[key] anymore, but table.get(key) instead. That is why I deleted those [] procs at first. But then, OTOH, the "get" template is not marked with a "*", so you cannot use it instead of "[]" anyway!
Does that mean that "[]" is not deprecated after all?
import tables
proc testAll(): void =
var t = newTable[int,int]()
t[1] = 2
echo($t.get(1))
testAll()
when defined(nimTableGet):
{.pragma: deprecatedGet, deprecated.}
else:
{.pragma: deprecatedGet.} # active branch: a nop
It's not deprecated. The nimTableGet define was introduced in order to help people migrate Nim code from some version where [] returned default(T) to some other version where [] began to raise an exception.