On Sunday, 16 January 2022 at 11:43:40 UTC, Ali Çehreli wrote:

So, in all three examples it is the same D feature, a slice, that references data but the data is managed in different ways.

Ali

Well, it's fair to say, that 'range-based programming' is kinda new to me.

With this statement:
 int[][] mArr = iota(1, 9).chunks(2).map!array.array;

- one would intuitively expect, that at the end, you end up with a dynamically allocated array, intialised with it's argument.

That is, you would expect some GC allocation to be going on, similar to what would happen with this code:

int[][] mArr2 = [[1, 2], [3, 4], [5, 6], [7, 8]]; // GC allocation

But it turns out:

int[][] mArr = iota(1, 9).chunks(2).map!array.array; // no GC allocation going on at all, not anywhere.

How can this be I asked myself?

Then I watched this, and learn about 'memory disallocation'.

http://dconf.org/2015/talks/bright.html

Now I understand.. I think ;-)


  • Dynamic array ot not forkit via Digitalmars-d-learn
    • Re: Dynamic array ot not Ali Çehreli via Digitalmars-d-learn
      • Re: Dynamic array ot... forkit via Digitalmars-d-learn
        • Re: Dynamic arra... Ali Çehreli via Digitalmars-d-learn
          • Re: Dynamic ... Salih Dincer via Digitalmars-d-learn
            • Re: Dyn... Ali Çehreli via Digitalmars-d-learn
              • Re:... H. S. Teoh via Digitalmars-d-learn
              • Re:... Ali Çehreli via Digitalmars-d-learn
            • Re: Dyn... Era Scarecrow via Digitalmars-d-learn
          • Re: Dynamic ... forkit via Digitalmars-d-learn
            • Re: Dyn... Ali Çehreli via Digitalmars-d-learn
              • Re:... forkit via Digitalmars-d-learn
                • ... Ali Çehreli via Digitalmars-d-learn
                • ... forkit via Digitalmars-d-learn
                • ... Steven Schveighoffer via Digitalmars-d-learn
                • ... forkit via Digitalmars-d-learn
                • ... Steven Schveighoffer via Digitalmars-d-learn
                • ... forkit via Digitalmars-d-learn
                • ... Salih Dincer via Digitalmars-d-learn
                • ... Salih Dincer via Digitalmars-d-learn

Reply via email to