MantisBT - Ecere SDK
View Issue Details
0000513Ecere SDKcompilerpublic2010-07-28 15:092014-07-11 18:12
jerome 
 
highfeaturehave not tried
newopen 
 
0.45 Ginkakuji 
0000513: More Consistent Reference Counting: Block Scope
Class objects declaration-instantiated (non anonymous) within a local block will now start with a reference count of 1 (instead of 0 as it is right now).

At the end of the block's scope they will now get decref'ed.

This will make it a lot more consistent with struct objects, as well as with global and member object instantiations, and will take away many cases of having to explicitly deal with memory management.
No tags attached.
related to 0000177new  eC String Solution 
Issue History
2010-07-28 15:09jeromeNew Issue
2010-07-29 15:29jeromeRelationship addedchild of 0000003
2010-07-29 15:29jeromeRelationship deletedchild of 0000003
2010-07-29 15:30jeromeRelationship addedchild of 0000431
2012-03-08 16:51redjTarget Version => 0.45 Ginkakuji
2012-03-08 21:21redjRelationship deletedchild of 0000431
2012-03-29 07:50redjCategory => eC Compiling Tools
2012-03-29 07:50redjProject@2@ => Ecere SDK
2013-04-25 09:43jeromeTarget Version0.45 Ginkakuji => 0.44.4 Strings
2014-01-24 02:57nicktickNote Added: 0001155
2014-01-24 02:59nicktickNote Added: 0001156
2014-05-04 04:02jeromeNote Added: 0001270
2014-05-04 07:34jeromeNote Edited: 0001270
2014-05-04 10:46jeromeRelationship addedrelated to 0000177
2014-05-08 05:33jeromeNote Added: 0001279
2014-05-08 07:53jeromeNote Added: 0001280
2014-07-11 18:12jeromeTarget Version0.44.30 Strings => 0.45 Ginkakuji

Notes
(0001155)
nicktick   
2014-01-24 02:57   
Add an example of the destructor of a class would never be called:

import "ecere"

class Form1 : Window
{
   caption = "Form1";
   background = formColor;
   borderStyle = sizable;
   hasMaximize = true;
   hasMinimize = true;
   hasClose = true;
   clientSize = { 576, 392 };

   bool OnCreate(void)
   {
      int i;
      for(i=1;i<=10;i++)
      {
         Test::test(10000000);
         printf("round %d\r\n\r\n",i);
         Sleep(1);
      }
      return true;
   }
}


class Test
{
  int _size;
  byte *p;
public:
  property int size
  {
     get{ return _size; }
     set{ _size = value; p = new byte[_size]; p[0]= 0xff;}
  }
  ~Test()
  {
     delete p; //would never be called now.
  }
  void ::test(int size)
  {
      Test t;
      t = Test{size = size};
      delete t;
  }
}

Form1 form1 {};
(0001156)
nicktick   
2014-01-24 02:59   
should comment the "delete t" in void ::test(int size).
(0001270)
jerome   
2014-05-04 04:02   
(edited on: 2014-05-04 07:34)
We may want to go with full reference counting, with the introduction of a special syntax to declare weak references (e.g. Object ^handle) as a way to avoid reference cycles.

(0001279)
jerome   
2014-05-08 05:33   
Once we've got reference counting, look at providing libgmp bindings again.
(0001280)
jerome   
2014-05-08 07:53   
Now re-considering the idea of full reference counting to instead stick to:

- Starting local ref count at 1 and auto deleting at the end of the scope
- Object object = { } // Make that start at ref count 1 as well
                      This would still require a delete object as it does now.
- PrintLn(Object { }) // Auto increfing/decrefing that as well
- Window { }.Modal() // that as well
- Adding struct destructors