http://d.puremagic.com/issues/show_bug.cgi?id=11240
--- Comment #2 from Kenji Hara <[email protected]> 2013-10-13 01:18:08 PDT --- (In reply to comment #1) > Is this valid though? > > assumeSafeAppend is an unsafe function that *requires* no one else have a view > on the items after the end of the array. > > Just the same, you will overwrite the old items, without destroying them, nor > assigning over them. > > I think this is just an unsafe function that was used wrong. The result is > simply undefined behavior. > > I think it would be a needless restriction to not allow assumeSafeAppend on > immutable (and const). > > This seems invalid to me. Because the unsafe-ness is hidden in assumeSafeAppend function template. If you pass immubtale(int)[] array reference to it in generic code, it could easily break type-system silently (And yes, I didn't noticed the risk until now). As the API design, it would be better to reject such a misuse. In other words, if you really wants to charge the capacity of immutable(int)[], enforcing explicit cast on caller side would be better. immutable(int)[] a = ...; //a = assubeSafeAppend(a); // compile error a = cast(typeof(a))aassubeSafeAppend(cast(int[])a); // ugly, but explicit -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
