"Jesse Phillips" <jessekphillip...@gmail.com> wrote in message news:j5gfsa$2d5g$1...@digitalmars.com... > Thank you this lets it compile. I think I had that somewhere, but forgot > about it. As Steve mentions, it probably should also work for const > arguments too.
It probably will, eventually. Some expressions can be proven to be pure (in some situations), such as (new C), (arr ~ arr), (arr.dup) and (thisFunctionIsConstPure(args)) (doing this for arr ~ arr is the best solution to http://d.puremagic.com/issues/show_bug.cgi?id=1654, in my opinion) As Steven pointed out, pure functions that have mutable return types cannot be opimized out, as the code could reasonably rely on returned objects being distinct. Their return values can, however, be converted to immutable without any problems.