Skip to content

Commit 6836d33

Browse files
authored
Merge pull request #3072 from ibuclaw/rm-deallocators
Remove documentation on class deallocators
2 parents b7fcc79 + 557c0df commit 6836d33

File tree

1 file changed

+0
-55
lines changed

1 file changed

+0
-55
lines changed

spec/class.dd

Lines changed: 0 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,6 @@ $(UL
6969
$(LI $(RELATIVE_LINK2 invariants, Class Invariants))
7070
$(LI $(DDSUBLINK spec/unittest, unittest, Unit Tests))
7171
$(LI $(RELATIVE_LINK2 allocators, Class Allocators))
72-
$(LI $(RELATIVE_LINK2 deallocators, Class Deallocators))
7372
$(LI $(RELATIVE_LINK2 alias-this, Alias This))
7473
)
7574
)
@@ -1070,60 +1069,6 @@ new(1,2) Foo(a); // calls new(Foo.sizeof,1,2)
10701069
Explicit Class Instance Allocation).
10711070
)
10721071

1073-
$(H2 $(LNAME2 deallocators, Class Deallocators))
1074-
$(B Note): Class deallocators and the delete operator are deprecated in D2.
1075-
Use the $(D destroy) function to finalize an object by calling its destructor.
1076-
The memory of the object is $(B not) immediately deallocated, instead the GC
1077-
will collect the memory of the object at an undetermined point after finalization:
1078-
1079-
------
1080-
class Foo { int x; this() { x = 1; } }
1081-
Foo foo = new Foo;
1082-
destroy(foo);
1083-
assert(foo.x == int.init); // object is still accessible
1084-
------
1085-
1086-
$(GRAMMAR
1087-
$(GNAME Deallocator):
1088-
$(D delete) $(GLINK2 function, Parameters) $(GLINK2 function, FunctionBody)
1089-
)
1090-
1091-
$(P A class member function of the form:)
1092-
1093-
------
1094-
delete(void *p)
1095-
{
1096-
...
1097-
}
1098-
------
1099-
1100-
is called a class deallocator.
1101-
The deallocator must have exactly one parameter of type $(D void*).
1102-
Only one can be specified for a class.
1103-
When a delete expression:
1104-
1105-
------
1106-
delete f;
1107-
------
1108-
1109-
is executed, and f is a reference to a class instance that has a deallocator,
1110-
the deallocator is called with a pointer to the class instance after the
1111-
destructor (if any) for the class is called. It is the responsibility of the
1112-
deallocator to free the memory.
1113-
1114-
$(P Derived classes inherit any deallocator from their base class,
1115-
if one is not specified.
1116-
)
1117-
1118-
$(P The class allocator is not called if the instance is created
1119-
on the stack.
1120-
)
1121-
1122-
$(P See also
1123-
$(LINK2 https://wiki.dlang.org/Memory_Management#Explicit_Class_Instance_Allocation,
1124-
Explicit Class Instance Allocation).
1125-
)
1126-
11271072
$(H2 $(LEGACY_LNAME2 AliasThis, alias-this, Alias This))
11281073

11291074
$(GRAMMAR

0 commit comments

Comments
 (0)