Check-in [413ff82ed0]

Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Clarify private method name interactions.
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 413ff82ed019813c2c7e4f80bf22fc94010eab4c0a4beaaefe22631e7c30b788
User & Date: dkf 2018-05-28 16:08:39.772
Context
2018-05-28
16:17
Updated the abstract check-in: b619dfd132 user: dkf tags: trunk
16:08
Clarify private method name interactions. check-in: 413ff82ed0 user: dkf tags: trunk
13:29
Fix 474 header formatting: add tabs check-in: 91cbaab07a user: dkf tags: trunk
Changes
Unified Diff Ignore Whitespace Patch
Changes to tip/500.md.
104
105
106
107
108
109
110






111
112
113
114
115
116
117
118
119
120





121
122
123
124
125
126
127
Once the call chain is created, the execution is handled as prior to this TIP;
the implementation of the first element on the call chain is executed,
whatever that is, and that can dispatch to later items on the call chain using
**next** and **nextto**.

A private method on a class (or object) may not have the same name as another
method on that class; all methods of a class (or object) are part of a single






space of names. When resolving a method call of a subclass of the class that
has the private method, even if the method names match, the private method
does not participate in the call chain; only an exact match from exactly the
right context counts.
Applying **export** or **unexport** to a private method will make that method
cease to be private, but it must be used on the same context (class or
instance) that defined the method; subclasses or instances cannot export or
unexport a private method defined by their superclass/class (respectively).
There is no mechanism for making an existing method private; that needs to be
done at method creation time.






In particular:

    oo::class create Top {
        method Foo {} {
            puts "This is Top::Foo for [self]"
        }







>
>
>
>
>
>
|









>
>
>
>
>







104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
Once the call chain is created, the execution is handled as prior to this TIP;
the implementation of the first element on the call chain is executed,
whatever that is, and that can dispatch to later items on the call chain using
**next** and **nextto**.

A private method on a class (or object) may not have the same name as another
method on that class; all methods of a class (or object) are part of a single
space of names. Creating a public or unexported method with the same name in
the same declaration context will delete the private method, just as it would
delete any other visibility of method defined on the same scope; this is
assumed to be a minor issue for most code as the methods on a particular class
(as opposed to its superclasses, subclasses or instances) are assumed to be
strongly cooperative with each other.
When resolving a method call of a subclass of the class that
has the private method, even if the method names match, the private method
does not participate in the call chain; only an exact match from exactly the
right context counts.
Applying **export** or **unexport** to a private method will make that method
cease to be private, but it must be used on the same context (class or
instance) that defined the method; subclasses or instances cannot export or
unexport a private method defined by their superclass/class (respectively).
There is no mechanism for making an existing method private; that needs to be
done at method creation time.
Method declarations on other declaration contexts (e.g., on subclasses) do not
affect private methods at all. Private methods cannot be used for filter
implementations; the caller's context is not considered when resolving filters
so private methods are ignored (though a filter implementation may of course
call a private method).

In particular:

    oo::class create Top {
        method Foo {} {
            puts "This is Top::Foo for [self]"
        }