Highest Rated Comments


adr869 karma

A big improvement for the phobos thing would actually be to make more use of output ranges instead of necessarily returning strings, etc. Then the caller can preallocate memory or whatever they want.

adr867 karma

Obviously he has never played Empire: once you start playing it, you never really stop and you disappear from the real world for a while!

adr866 karma

I think the C++ resource model mostly rox and that's one reason why I like D: you can still do it, and that is how files and some objects are handled. (Indeed, I've used D with a custom runtime and a few rules to make it completely gc free).

But with memory, it can be ambiguous who the owner should be and that's where the gc (and immutability) can help. Stuff like taking a slice of an array, or circular references, is very nice, and being able to store it with some sanity is nice too.

adr864 karma

We must implement scope params!

adr863 karma

I feel that replacing the global allocator is a huge mistake, unless your whole program is doing it (that is, a customized druntime and libraries).

For example, if you replaced the gc with malloc then called the typical function, odds are very high it will leak because it doesn't know it needs to call free(). Or it will return a pointer and store one, then it gets freed, and the stored one is now invalid.

This is easy to handle if the function knows what is going on.... but at that point, it should just take the allocator argument, not replace the global one. Replacement is action at a distance that can turn a previously correct program into a buggy one.

If you want to use a region allocator for temporaries, 1) how do you know what is temporary? What if the function returns a slice into one of those things? and 2) this is what generational gcs are meant to solve anyway, so we should just fix the global gc rather than replace it at random.