Replies: 1 comment
|
Minor: Your code doesn't compile: Major:
Consider this code: public class Elem
{
public Elem()
{
}
public void Init(string label)
{
Label = label;
}
string() Label;
}
class Test
{
List<Elem()>() MyList;
void Init()
{
MyList.Add();
MyList.Add();
MyList.Add();
MyList[0].Init("A");
MyList[1].Init("B");
MyList[2].Init("C");
}
}It's shorter, more performant and doesn't have any leaks or dangling references.
Implemented in 9589f83. Thanks!
This is also wrong. You should return
Not sure what you mean? Remove object storage, read-only and read-write references from Ć? I expect them to be used much often than dynamic references. |
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
We have
in C++ code, both methods (make3cyclic and make3nonCyclic) have no cycles becuse all elements are freed but return pointer to freed memory.
My idea: in second function where is
Elem() Ashould be denied return elem, allowed in first where isElem# A = new Elem()next: everywhere use shared_ptr's instead of raw pointer, although this can lead to memory cycles.
Must be class to detect and analyze cycles. If will both
nextandprevfields - only one must be strong, rest mu be weak - keywordweak. Similar : in tree child list is strong, parent is weak (I don't now how compiler can avoid reverse situation : parent strong, childs list weak).Probably is impossible detect all cycle situation, in cyclic list, before end block in c++ can be
All unclear cycle situation compiler must deny.
ASK: only in c++/swift code, Garbage Collector can handle all ? or better deny at all these unclear situation (compiler will more permissive than Rust anyway (?))
All reactions