@adrien79 Yes, that's how it works. There is no items for types, as far as I
know.
> I guess this is because the array declaration expects a type whereas my const
> AllPoints is a slice, but I don't fully understand the details.
Correct, when you use type you define a subrange, but with const it's a slice.
As you can read in the docs, array declaration expects an ordinal type
No, I'm iterating like this at several places and it works fine:
type Point = range[0 .. 360]
const AllPoints = Point(0) .. Point(360)
for pt in AllPoints:
do_sth(pt)
What I can't do is insert the same `AllPoints` in the array type declaration:
type MyArra
@adrien79 Actually, if you tried to iterate over Points as you illustrated, it
would break too:
for pt in Points:
do_sth(pt)
You should use explicit low and high:
for pt in Points.low .. Points.high:
do_sth(pt)
Thanks, this works to define the array, but then it breaks this in other places:
for pt in AllPoints:
do_sth(pt)
No matter, I've just realized that I can use `low` and `high` with a type, I'll
use this:
type MyArray = array[Point.high .. Point.low, int]
try
type
Point = range[0 .. 360]
AllPoints = Point(0) .. Point(360)
MyArray = array[AllPoints, int]
I want to define an array indexed by another type. I can make it work like this:
type Point = range[0 .. 360]
...
type MyArray = array[Point(0) .. Point(360), int]
but not like this:
type Point = range[0 .. 360]
const AllPoints = Point(0) .. Point(360)