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

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sat Apr 27 22:50:41 PDT 2013


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



--- Comment #27 from Kenji Hara <k.hara.pg at gmail.com> 2013-04-27 22:50:37 PDT ---
I think this is doable enhancement with sane rule.

>From 2.061, we have a 'unique expression' in certain cases.

  pure int[] newArr(int n) { return new int[](n); }
  immutable int[] arr = newArr(3);
  // newArr(3) creates an unique array, so it is implicitly convertible to
  // immutable

  class MyClass {}
  immutable MyClass c = new MyClass();
  // Raw NewExpression creates an unique object, so it is implicitly
convertible
  // to immutable.

>From 2.063, qualified constructor supports creating 'unique object'.

  struct MyObj { this(int) pure {} }
  immutable MyObj *p = new MyObj(1);
  // this(int) pure makes 'unique object', so the created object is implicitly
  // convertible to immutable.

Based on the 'unique expression' concept, we can consider that an array
concatenation creates 'unique expression' when some conditions are satisfied.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list