Bill Baxter wrote:
On Mon, Oct 19, 2009 at 5:07 PM, Andrei Alexandrescu
<seewebsiteforem...@erdani.org> wrote:
Rainer Deyke wrote:
Andrei Alexandrescu wrote:
One surprising (but safe) behavior that remains with slices is this:

void fun(int[] a) {
  a[0] = 0;
  a ~= 42;
  a[0] = 42;
}

The caller may or may not see 42 in the first slot after the call.
Your definition of "safe" is clearly not aligned with mine.


What's yours?

Probably something like "safe from easy-to-write hard-to-debug
programming errors".

I agree that it would stink if all these changes were made and *still*
one of the top gotchas with arrays/slices remained.  It also makes me
think slices and appending just don't belong together.  Appending to a
view ... just say no.

How to reconcile this viewpoint with that of people who find ~= all too darn convenient?

Andrei

Reply via email to