It appears compiler allows`` uint(str.len) `` but not `` uint(-1) `` so can infer string length integer never negative ? If a function disallows negative number for a particular parameter, it seems reasonable to declare the type of that parameter as unsigned to avoid the cost of an extra precondition check.
According to the manual Nim supports subrange types, so is `type Offset = range[0..high(int)]` more idiomatic for declaring non-negative arguments for functions dealing with strings? Is there any runtime overhead?