What should we call the explicit object destruction method?
Summary of issue:
Per feedback from #7362, the discussion for naming the explicit object destruction method has been moved to a leads question.
Details:
The following names have been considered:
| Name | Function | Method | Preference |
|---|---|---|---|
SelfDestruct |
SelfDestruct(x) |
x.SelfDestruct() |
1 |
DestroyObject |
DestroyObject(x) |
x.DestroyObject() |
2 |
DestroySelf |
DestroySelf(x) |
x.DestroySelf() |
3 |
CompleteDestroy |
CompleteDestroy(x) |
x.CompleteDestroy() |
4 |
ManualDestroy |
ManualDestroy(x) |
x.ManualDestroy() |
5 |
ExplicitDestroy |
ExplicitDestroy(x) |
x.ExplicitDestroy() |
6 |
ManualDestroy is not recommended because they make it awkward to reason about implicit object destruction without some complement (for example AutoDestroy). The toolchain would implicitly call AutoDestroy, and users would call ManualDestroy. This would probably need to show up in stacktraces, which adds to their obfuscation. We could potentially do some amount of inlining, but this could cause confusion about what is responsible for destroying an object. Similarly for ExplicitDestroy.
The remaining options are all appropriate for both situations. As such, we end up with a subjective decision.
CompleteDestroyproduces an incomplete phrase.DestroySelfcould potentially be mixed up withDestroy.Destroy(self).DestroyObjectclearly articulates the operation and user intent. It also renders nicely in other contexts, such as documentation and stacktraces.SelfDestructhas the same benefits asDestroyObject. "Self-destruct" additionally refers to an internal mechanism for destroying an entity. That "internal mechanism"Core.Destroy.Opfor Carbon object tear-down.
Any other information that you want to share?
Some of the points brought up in #7508 are also relevant here.
Source: carbon-language/carbon-lang