TIP 516: More OO Slot Operations

Author:         Donal K. Fellows <[email protected]>
State:          Final
Type:           Project
Vote:           Done
Created:        7-Sept-2018
Tcl-Version:	8.7
Keywords:       Tcl, TclOO
Vote-Results:   4/0/5 accepted
Votes-For:      DKF, JN, JD, AK
Votes-Against:  none
Votes-Present:  BG, KBK, DGP, FV, SL
Tcl-Branch:     tip-516


This TIP proposes to add some more operations to slots by updating the class that implements them.


Currently slots support setting (i.e., replacing all current slot items with a different list of items), appending (i.e., adding onto the end of the list), and clearing (i.e., setting the list to an empty list); the former two cases are moderated by the need for slot items to be unique, but that is a constraint enforced at the lower level. However, other basic operations are conceivable too, such as prepending an item and removing an item (with the latter needing a little care as it requires normalisation of the slot items). An example of how this last use case might be useful is when removing a behaviour from an object by removing a mixin from it; that's possible to do with the existing code, but quite awkward because it requires replacing the list of slot items with another list, and so it is an operation that we should provide by default.


This will add two new methods to the ::oo::Slot class:

To support this, an extra internal operation is added:


See the tip-516 branch.


This document has been placed in the public domain.