[Issue 1654] Array concatenation should result in mutable or invariant depending on usage

d-bugmail at puremagic.com d-bugmail at puremagic.com
Thu Jan 31 12:30:21 PST 2008


http://d.puremagic.com/issues/show_bug.cgi?id=1654





------- Comment #2 from schveiguy at yahoo.com  2008-01-31 14:30 -------
Thank you for looking at this issue.  You are correct in your statement that my
proposed solution does not solve your specific example.  There could be other
examples, such as if you had a struct S that contained a pointer, then
concatenating an invariant(S)[] into a mutable S[] would result in the pointer
violating the immutability.

However, this could be alleviated if we had the following rule:

if X is a data type, and v1 is of the type invariant(X) and v2 is of the type
X, it is allowed to copy v1 to v2 provided that the X data type is not a
pointer or a reference or contains any pointers or references.

I think this rule is sound and really should be an enhancement on its own, but
it provides a way that my solution could work.  With this rule, my example
passes the rule since copying an invariant(char) to a char is allowed, but your
example fails because copying an invariant(int[]) to a int[] fails.

What do you think?


-- 



More information about the Digitalmars-d-bugs mailing list