Purpose of the Range object

Hi All,

I wanted to return values of Range type so that it becomes clear in the end-users mind that we are talking about a number range and will be used as a pages iterator. But, I realize the only way to create a Range is with the function range. The Range object per-se is not documented and just mapped to UnionAll.

Is it the right usage or Range object? Or is it intended more from a set theoretic relationship like a domain range [1,55.5) use case. I see various mathematical and statistical operations on it.

I can return a Tuple{Int,Int} or Pair{Int, Int} but both do not provide the same clarity as Range.

regards,

Sambit

Range is an abstract type, so a value cannot have this type, only a subtype of Range.

For integers, UnitRange should be fine. You can use the a:b constructor. The most commonly understood meaning is โ€œall integers between a and b, inclusiveโ€, but you can use it for anything you like.

For floating point intervals, various packages have different implementations, with different semantics.

Unfortunately, the Range object concrete types are not documented clearly. From the REPL help.

help?> UnitRange
search: UnitRange AbstractUnitRange

  No documentation found.

  Base.UnitRange is of type UnionAll.

     Summary
    โ‰กโ‰กโ‰กโ‰กโ‰กโ‰กโ‰กโ‰กโ‰ก

  struct UnionAll <: Type{T}

     Fields
    โ‰กโ‰กโ‰กโ‰กโ‰กโ‰กโ‰กโ‰ก

  var  :: TypeVar
  body :: Any

     Supertype Hierarchy
    โ‰กโ‰กโ‰กโ‰กโ‰กโ‰กโ‰กโ‰กโ‰กโ‰กโ‰กโ‰กโ‰กโ‰กโ‰กโ‰กโ‰กโ‰กโ‰กโ‰กโ‰ก

  UnionAll <: Type{T} <: Any

help?> AbstractUnitRange
search: AbstractUnitRange

  No documentation found.

  Base.AbstractUnitRange is of type UnionAll.

     Summary
    โ‰กโ‰กโ‰กโ‰กโ‰กโ‰กโ‰กโ‰กโ‰ก

  struct UnionAll <: Type{T}

     Fields
    โ‰กโ‰กโ‰กโ‰กโ‰กโ‰กโ‰กโ‰ก

  var  :: TypeVar
  body :: Any

     Supertype Hierarchy
    โ‰กโ‰กโ‰กโ‰กโ‰กโ‰กโ‰กโ‰กโ‰กโ‰กโ‰กโ‰กโ‰กโ‰กโ‰กโ‰กโ‰กโ‰กโ‰กโ‰กโ‰ก

  UnionAll <: Type{T} <: Any

I am sure pull requests for documentation would be welcome; however, most of the documentation for UnitRange would be found in the manual where : is discussed. These would be a good start.

Thanks @Tamas_Papp

I have created an issue as well. https://github.com/JuliaLang/julia/issues/23421