On 07/03/2012 15:41, Steven Schveighoffer wrote:
<snip>
In fact, I think this is valid D code:

int i;
const int *pi = &i;
int *p = cast()pi;
*p = 5; // legal because I know this points at i, and i is really mutable

cast() is an abomination.  I'm not sure OTTOMH whether it's a bug that it works.

But from an API point of view, I look at at inout as guaranteeing anything the 
parameter
points at won't change while inside the function *using that parameter*. Even 
though it's
legal, it's disingenuous (at least as long as we define inout that way).

That's what const is for.

The whole point of inout is that the caller has the choice of whether to pass in and get out again mutable, const or immutable data. Allowing the caller to pass in a delegate with a mutable, const or immutable parameter would fit right in with this.

<snip>
As usual, you find and poke holes in all my arguments :) I'm thinking that in 
order to
make this work we need a way to specify an inout modifier really represents the 
matched
type rather than a full-fledged inout parameter.
<snip>

Yes, and ways of specifying this have been suggested early in this thread.

Stewart.

Reply via email to