On Tuesday, April 17, 2012 19:22:30 André Stein wrote: > Hi, > > I'm trying to pass the range returned by iota to a function accepting > the parameter as const. I got compilation errors when trying to use the > index operator and after some investigation it turned out that opSlice > of iota.Result isn't declared as const. > > The function body of opSlice of iota.Result doesn't seem to mutate the > range so is there any special reason why it isn't declared as such? (the > same holds for opSlice).
Very little on ranges ends up being marked const, because const ranges tend to be useless (since you can't iterate over them). There are a few cases where you could use a range function even if the range is const (this at least appears to be one of them), but const typically gets forgotten simply because const ranges are generally useless. You can open an enhancement request ( d.puremagic.com/issues ) for this though. - Jonathan M Davis