--- Comment #2 from Steven Schveighoffer <> 2011-02-24 
12:47:49 PST ---
(In reply to comment #0)

> Michel Fortin also noticed a nice-to-have: if at the call site you know that
> all the arguments you're feeding the function with are immutable, then you can
> automatically cast the result to immutable, even if the function can also
> accept const arguments.

Note actually that as long as you can verify the return value did not come
directly from the parameters, it's also possible to implicitly cast to

For example:

pure T[] mydup(T)(const(T)[] param) {...}

It's provable that the return value did not come from param (without a cast),
because you can't implicitly cast param to T[].  So you can cast the result to
immutable, even if param began as mutable.

This might be really tricky to implement though, there can be all sorts of
weird cases.

But if this could be accomplished, it would completely negate the need for

Configure issuemail:
------- You are receiving this mail because: -------

Reply via email to