@@ -939,28 +939,24 @@ Note: Users should prefer $(REF destroy, object)` to explicitly finalize objects
939939and only resort to $(REF __delete, core,memory) when $(REF destroy, object)
940940would not be a feasible option.
941941
942- In detail, `__delete` does the following:
942+ In detail, `__delete(x)` returns with no effect if `x` is `null`. Otherwise, it
943+ performs the following actions in sequence:
943944$(UL
944-
945- $(LI If `t` is a class object reference, and
946- there is a destructor for that class, the destructor
947- is called for that object instance.
948- )
949- $(LI Otherwise, the garbage collector is called to immediately free the
950- memory allocated for the class instance or struct instance.
951- If the garbage collector was not used to allocate the memory for
952- the instance, undefined behavior will result.
945+ $(LI
946+ Calls `.object.destroy(*x)` (if `x` is a pointer) or `.object.destroy(x)`
947+ (otherwise) to destroy the referred entity.
953948 )
954- $(LI If `t` is a pointer or a dynamic array,
955- the garbage collector is called to immediately release the
956- memory.
957- If the garbage collector was not used to allocate the memory for
958- the instance, undefined behavior will result.
949+ $(LI
950+ Frees the memory allocated for `x`. If `x` is a reference to a class
951+ or interface, the memory allocated for the underlying instance is freed. If `x` is
952+ a pointer, the memory allocated for the pointed-to object is freed. If `x` is a
953+ built-in array or associative array, the memory allocated for the array is freed.
954+ If `x` does not refer to memory previously allocated with `new` (or the lower-level
955+ equivalents in the GC API), the behavior is undefined.
959956 )
960- $(LI The pointer, dynamic array, or reference is set to `null`
961- after the delete is performed.
962- Any attempt to reference the data after the deletion via another
963- reference to it will result in undefined behavior.
957+ $(LI
958+ Lastly, `x` is set to `null`. Any attempt to read or write the freed memory via
959+ other references will result in undefined behavior.
964960 )
965961)
966962
0 commit comments