-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Closed
Labels
leads questionA question for the leads teamA question for the leads team
Description
Summary of issue:
How should Destroy work for classes?
The two main options are:
- Have a blanket
implnext toDestroywhich covers all classes that should supportDestroy. - Generate an
impl as Destroyas part of eachclassdefinition.- This would likely behave similarly as if users wrote that inside the
classdefinition, particularly to supportclass C { class Nested {} var n: Nested; }
- This would likely behave similarly as if users wrote that inside the
Details:
At present, we already expect to have blanket impls for other types implementing Destroy. For example: tuples, structs, arrays, T*, const T, and MaybeUnformed(T).
class is slightly different because classes are expected to have custom destroy functions, and have a definition owned by a specific library (in contrast with tuples).
There was significant discussion about what users should see, and what limits were desired, in the toolchain meeting on Sep 23.
Prior to the meeting, zygoloid and I had also discussed possible performance differences:
- In a blanket
implapproach, oneimplis imported for all types. Each type gets its own specific. Impl lookup would need to test against the blanketimplon the first lookup, but could in theory cache results (not yet implemented). - In a per-
classapproach, there manyimpls, and each is imported separately. However, in theory impl lookup can look at only theimplthat applies (though it may still need to examine and rule out blanketimpls).
The discussion about performance was set aside since it didn't seem as compelling about the discussion about desired behavior.
Metadata
Metadata
Assignees
Labels
leads questionA question for the leads teamA question for the leads team