Skip to content

Commit 3421e6a

Browse files
committed
Fix Issue 9433 - Deprecate delete
1 parent 1d4ffc6 commit 3421e6a

File tree

5 files changed

+12
-12
lines changed

5 files changed

+12
-12
lines changed

deprecate.dd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ $(SPEC_S Deprecated Features,
1515
$(TROW $(DEPLINK Implicit comparison of different enums), 2.075, 2.075,  ,  )
1616
$(TROW $(DEPLINK Implicit string concatenation), 2.072, 2.072,  ,  )
1717
$(TROW $(DEPLINK Using the result of a comma expression), 2.072, 2.072, 2.079,  )
18-
$(TROW $(DEPLINK delete), future,  ,  ,  )
18+
$(TROW $(DEPLINK delete),  , 2.079,  ,  )
1919
$(TROW $(DEPLINK scope for allocating classes on the stack), future,  ,  ,  )
2020
$(TROW $(DEPLINK Imaginary and complex types), future,  ,  ,  )
2121
$(TROW $(DEPLINK Implicit catch statement), 2.072, 2.072, future, future )

spec/class.dd

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -632,11 +632,10 @@ $(GNAME Destructor):
632632
object.
633633
)
634634

635-
$(P The program can explicitly inform the garbage collector that an
636-
object is no longer referred to (with the delete expression), and
637-
then the garbage collector calls the destructor
638-
immediately, and adds the object's memory to the free storage.
639-
The destructor is guaranteed to never be called twice.
635+
$(P The program can explicitly inform the garbage collector that an
636+
object is no longer referred to with $(REF1 destroy, object), and
637+
then the garbage collector calls the destructor immediately. The
638+
destructor is guaranteed to never be called twice.
640639
)
641640

642641
$(P The destructor for the super class automatically gets called when
@@ -654,8 +653,8 @@ $(GNAME Destructor):
654653
members that are references to garbage collected objects, those
655654
references may no longer be valid. This means that destructors
656655
cannot reference sub objects.
657-
This rule does not apply to auto objects or objects deleted
658-
with the $(I DeleteExpression), as the destructor is not being run
656+
This rule does not apply to auto objects or objects destructed
657+
with $(REF1 destroy, object), as the destructor is not being run
659658
by the garbage collector, meaning all references are valid.
660659
)
661660

spec/expression.dd

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -732,6 +732,9 @@ $(GRAMMAR
732732
$(GNAME DeleteExpression):
733733
$(D delete) $(GLINK UnaryExpression)
734734
)
735+
$(P NOTE: `delete` has been deprecated. Instead, please use $(REF1 destroy, object)
736+
if feasible, or $(REF __delete, core, memory) as a last resort.)
737+
735738
$(P If the $(I UnaryExpression) is a class object reference, and
736739
there is a destructor for that class, the destructor
737740
is called for that object instance.

spec/function.dd

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2395,7 +2395,6 @@ $(H2 $(LNAME2 nogc-functions, No-GC Functions))
23952395
$(LI $(DDSUBLINK expression, IndexExpression, indexing) an associative array
23962396
(because it may throw $(D RangeError) if the specified key is not present))
23972397
$(LI $(DDSUBLINK expression, NewExpression, allocating an object) on the heap)
2398-
$(LI $(DDSUBLINK expression, DeleteExpression, deleting an object) on the heap)
23992398
)
24002399

24012400
---
@@ -2410,7 +2409,6 @@ $(H2 $(LNAME2 nogc-functions, No-GC Functions))
24102409
aa["abc"]; // error, indexing may allocate and throws
24112410

24122411
auto p = new int; // error, operator new allocates
2413-
delete p; // error, operator delete deallocates
24142412
}
24152413
---
24162414

spec/interface.dd

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ $(SECTION2 $(LEGACY_LNAME2 COM-Interfaces, com-interfaces, COM Interfaces),
240240

241241
$(UL
242242
$(LI It derives from the interface $(D core.stdc.windows.com.IUnknown).)
243-
$(LI It cannot be the argument of a $(I DeleteExpression).)
243+
$(LI It cannot be the argument to $(REF1 destroy, object).)
244244
$(LI References cannot be upcast to the enclosing class object, nor
245245
can they be downcast to a derived interface. To accomplish this,
246246
an appropriate $(D QueryInterface()) would have to be implemented
@@ -328,7 +328,7 @@ class Ifoo
328328
)
329329

330330
$(UL
331-
$(LI It cannot be the argument of a $(I DeleteExpression).)
331+
$(LI It cannot be the argument to $(REF1 destroy, object).)
332332
$(LI References cannot be upcast to the enclosing class object, nor
333333
can they be downcast to a derived interface.)
334334
$(LI The C++ calling convention is the default convention

0 commit comments

Comments
 (0)