On Wed, 07 Mar 2012 17:37:53 -0500, Stewart Gordon <smjg_1...@yahoo.com>
wrote:
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.
Sorry, it's just easier than typing cast(int*).
And I believe it's legal, as long as you *know* that the underlying data
is mutable. The above code snippit is legal, because it is shown as long
as the first two lines are included that the actual data is mutable.
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.
And inout. Sorry, it was meant that way, even if you don't agree.
-Steve