On Thursday, 30 January 2014 at 09:14:43 UTC, Cooler wrote:

Please stop explain me how fun3() works. I know that.
One of the main idea of D is that things must work as planned, or would not compile at all. First and second variants follow this idea. But fun3() can work not as planned on the caller side (depends on fun3() body's implementation). The question again - may be prohibit fun3() variant? If we prohibit it, what use cases we could not implement with fun1() and fun2()?

Goodness... You've been shown this use case like a zillion times already: the caller manages her buffer, fun3() is allowed to change contents, but not reallocate caller's buffer.

fun1() can't provide that (const), fun2() cannot either, because it explicitly allows reallocation (ref). This behavior is only provided by fun3().

So it's either that, or indeed cases of "I don't care about this array", which Maxim Fomin has mentioned.

Reply via email to