Michel Fortin napisał: > The interesting thing with this change is that you can now call > mutators functions on the local variables inside the pure function, > because those can be made pure. You can't even iterate over a range > inside a pure function without this! > > pure int test() { > int result; > auto r = iota(0, 10); > while (!r.empty) { > result += r; > r.popFront(); // can't be pure by current rules! > } > return result; > }
It's because popFront() can't be made pure. It could be if there was @tail immutable in the language -- pure functions would mark their arguments with @tail immutable instead of immutable. That allows popFront() to advance the range. I wrote about it before but the idea didn't catch on: http://www.digitalmars.com/webnews/newsgroups.php?art_group=digitalmars.D&article_id=11 6475 -- Tomek