In any case the use of Natural and Positive isn't really encouraged. They just 
haven't specifically been removed or deprecated, because there isn't _that_ 
much of a reason to.

They're not really useful either because they only work for `int`. A proper 
implementation would be like:
    
    
    type
      PositiveOrZero[T: SomeNumber] = range[T(0)..high(T)]
      Positive[T: SomeInteger] = range[T(1)..high(T)]
    
    proc foo(x: Positive[int]) = echo x
    foo(1)
    foo(-1) # error
    
    
    Run

But this doesn't compile due to some weird range generics bug so we have to use 
templates.
    
    
    template positiveOrZero(T: type SomeNumber): untyped = range[T(0)..high(T)]
    template positive(T: type SomeInteger): untyped = range[T(1)..high(T)]
    
    proc foo(x: positive int) = echo x
    foo(1)
    foo(-1) # error
    
    
    Run

Reply via email to