On Saturday, 20 May 2017 at 09:35:34 UTC, Stanislav Blinov wrote:
On Saturday, 20 May 2017 at 02:25:45 UTC, Walter Bright wrote:
  void foo(scope string s);

string s = callCAPIAndAllocateString();
foo(s ~ "abc");

What will happen? The compiler will generate different code? Won't compile? The former means invisible performance gap. The latter means an unpleasant surprise. Neither are good. Do we really need such special cases?

It's no different from when s is GC allocated, s[] has to be copied for the concatenation. I'm not sure how Walter wants to lower this, but maybe it could use a region/stacked allocator. That could mean allocation in constant time when the region is already big enough, and deallocation would be constant time (except if freeing an unused region ahead of the current region).

Reply via email to