On 03/09/2016 11:02 PM, Nick Treleaven wrote:
On Friday, 2 September 2016 at 11:42:57 UTC, rikki cattermole wrote:
I've got a much more advanced memory management solution[0].
I'm waiting on DIP1000 implementation before implementing it into it.

But over all I quite like this type approach.

[0]
https://github.com/rikkimax/alphaPhobos/blob/master/source/std/experimental/memory/managed.d#L255


OK. Looks quite complex. Do you have the docs generated anywhere?

Docs[0].

Before implementing as a library solution I was working on a language concept[1]. The basic idea is that the end user should never care about how memory is 'owned'. The main thing to know is that it isn't plain old data that you can do literally anything you want with it.

So these are valid transformations:
- managed!T -> scope T
- managed!(T[]) -> managed!(T[])
- managed!(T[]) -> T if(isBasicType!T)
- managed!(T[]) -> managed!T if(!isBasicType!T)

T cannot be a pointer but it can be an array, class, struct or primitive type. If you do pass a pointer it will *value so it acts as if it was typeof(*T.init) when accessing.

The current implementation is fairly dumb in that it does two allocations per memory instance. But that is an implementation detail.

So this is hugely over kill for most people but would be amazing what you could do for containers.

[0] http://cattermole.co.nz/docs/html/std_experimental_memory_managed.html
[1] https://wiki.dlang.org/User:Alphaglosined/ManagedMemory

Reply via email to