Skip to content

Commit

Permalink
Merge pull request #112 from AndrejMitrovic/classalocators
Browse files Browse the repository at this point in the history
Add deprecation notes about class allocators/deallocators.
  • Loading branch information
andralex committed Apr 8, 2012
2 parents 63b0fcf + b1d1f0e commit f8ef01e
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions class.dd
Expand Up @@ -748,7 +748,7 @@ assert(mydate); // check that class Date invariant holds
runs at maximum speed.

<h3>$(LNAME2 allocators, Class Allocators)</h3>

$(B Note): Class allocators are deprecated in D2.
$(GRAMMAR
$(GNAME ClassAllocator):
$(B new) $(GLINK2 declaration, Parameters) $(GLINK2 function, FunctionBody)
Expand Down Expand Up @@ -812,7 +812,18 @@ new(1,2) Foo(a); // calls new(Foo.sizeof,1,2)
)

<h3>$(LNAME2 deallocators, Class Deallocators)</h3>

$(B Note): Class deallocators and the delete operator are deprecated in D2.
Use the $(B clear) function to finalize an object by calling its destructor.
The memory of the object is $(B not) immediately deallocated, instead the GC
will collect the memory of the object at an undetermined point after finalization:

------
class Foo { int x; this() { x = 1; } }
Foo foo = new Foo;
clear(foo);
assert(foo.x == int.init); // object is still accessible
------

$(GRAMMAR
$(GNAME ClassDeallocator):
$(B delete) $(GLINK2 declaration, Parameters) $(GLINK2 function, FunctionBody)
Expand Down

0 comments on commit f8ef01e

Please sign in to comment.