D Language Foundation January 2024 Monthly Meeting Summary

Richard (Rikki) Andrew Cattermole richard at cattermole.co.nz
Tue May 14 22:28:58 UTC 2024


Wow I see I was mentioned at a lot at this meeting!

In saying that I do have some points to add about Item 2 data structures.

Data structures come in one of two forms generally: owning and non-owning.

### Non-owning

Non-owning is the simplest, its an index.
It doesn't own any memory that isn't internal.

Takes in a single memory allocator for its internal state.

For its memory safety you are pretty limited to concerns surrounding 
read-only-ness of its internal state. Which only exist because the GC 
allocator might be in use.

You pass a value in, you get a value out. No references.

### Owning

Owning data structures come with two subsets which may be mixed to form 
a third combined subset.

#### Cleans up

Takes in two memory allocators, one for its internal state, one for its 
deallocation of values.

Will deallocate any memory given to it, which also means that once 
memory is placed into it, it now owns it and is responsible for its cleanup.

As for memory safety you have only one (as long as you don't use 
references out).

Owner escape analysis, this is a DIP Walter has required for me to work 
on before reference counting. So its going in anyway.

#### References out

I'll assume here that it does not clean up any memory passed in, that 
you handle this manually, that the data structure is merely an index.

In almost all ways its similar to non-owning, one memory allocator, 
still has the memory safety concerns of the owner.

Andddddddd you also have to worry about borrows typically from a struct 
acting as a reference. Which once again is resolved with owner escape 
analysis (noticing a trend yet?).

------------------------------------------------------------------------

What this tells us is that non-owning data structures can go in pretty 
much immediately, although there will need to be some remedial work once 
we get reference counting and with that a solution to read only memory.

But of course because Walter wants owner escape analysis first, it 
doesn't matter, both owning and non-owning will need to go together.

Note: concurrent data structures will need the read only memory solution 
due to the locks (notice a trend yet?) as well.

We'll likely want to use long names to differentiate all these behaviors 
unfortunately. As it could be quite desirable to have all the different 
variations.


More information about the Digitalmars-d-announce mailing list