Closed ghost closed 6 months ago
Yes I was considering the potential benefits of reference counting although it does have it's problems of course like you referenced.
If there is first class reference counting, there would need to be an auxiliary method as well for when RC can't be used or is ill suited
What do you think about Objective C? Could Adept learn something from it?
If there is first class reference counting, there would need to be an auxiliary method as well for when RC can't be used or is ill suited
Both Modula-3 and Vala support manual memory management.
What do you think about Objective C? Could Adept learn something from it?
Objective C has good C compatibility and I am not that familiar with how it does reference counting.
What is certain, is that manual memory management must be available (due to the requirement to be able to directly-call/be-called-by C code)
Objective-C has some kind of object pools correct? So reference counting is cheaper?
For non-recursive datastructures, atomic reference counting could solve most problems, but for cyclic datastructures some kind of pool to hold the graph nodes would need to exist (like a container to hold a cyclic structure as a non-cyclic one).
Although bringing in either implicit/explicit lexical ownership modeling would be nice to help optimize away reference counting when possible.
Right now I'm thinking of something like what https://strlen.com/lobster/ does for memory management, a hybrid between reference counting and lexical ownership that's implicit so you get really good performance without having to actually think how your memory is being managed.
Objective-C has some kind of object pools correct?
I have never used Objective C. What I know about it are all from other people's comments on the internet that I have read. Most of the time, they praised Objective C. Btw, it seems this is what you are looking for:
https://developer.apple.com/documentation/foundation/nsautoreleasepool
Right now I'm thinking of something like what https://strlen.com/lobster/ does for memory management, a hybrid between reference counting and lexical ownership that's implicit so you get really good performance without having to actually think how your memory is being managed.
I'm sorry but I don't think I have enough knowledge to comment on this subject.
I'm not suggesting Adept follow Vala's model. I only want to present one more available option to you. It took me a whole day to write a VAPI file. The C library is not complex, but it took that long to make the binding because it needs to fit Vala's memory management model (and I hate it). Btw, I don't think I have enough knowledge to judge if Vala's model is good or bad, though.
Here is the document about Vala's Memory Management:
https://wiki.gnome.org/Projects/Vala/ReferenceHandling
This is the manual that I had to read many times before I could make my binding work:
https://wiki.gnome.org/Projects/Vala/ManualBindings