|
2014-08-28
| ||
| 07:58 | • Closed ticket [b9e1a3032e]: TclOO method lookup chooses object method over class... artifact: d487b4975d user: dkf | |
| 07:53 | [b9e1a3032e] Implement the documented method search order for TclOO. This corrects the relative posi... check-in: ab635c8161 user: dkf tags: trunk, potential incompatibility | |
|
2014-08-19
| ||
| 07:31 | • Ticket [b9e1a3032e] TclOO method lookup chooses object method over class mixin m... artifact: 42bd6ab9fb user: dkf | |
| 07:31 | • Ticket [b9e1a3032e]: 4 changes artifact: 07d32643ae user: dkf | |
| 07:19 | • Ticket [b9e1a3032e]: 4 changes artifact: e7ce7e78df user: dkf | |
|
2014-07-31
| ||
| 14:15 | • Ticket [b9e1a3032e]: 3 changes artifact: 7deb65b37e user: apnadkarni | |
|
2014-07-22
| ||
| 03:39 | • New ticket [b9e1a3032e]. artifact: f9ac72c098 user: apnadkarni | |
TclOO method lookup chooses object method over class mixin method
Closed / Fixedb9e1a3032eb1fb7811996bcbdddbeaa8004c589aCreated 12 years agoUpdated 12 years ago
Descriptionplain2014-07-22 03:39:29
The manpage for [next] states in the Method Search Order section that methods defined in classes mixed into classes of an object are searched before methods defined for the object. The following sample seems to show otherwise.
oo::class create ClassMixin {
method m {} {puts ClassMixin; next}
}
oo::class create ObjMixin {
method m {} {puts ObjMixin; next}
}
oo::class create C {
mixin ClassMixin
method m {} {puts C}
}
(tcl) 82 % C create o
::o
(tcl) 83 % oo::objdefine o {mixin ObjMixin}
(tcl) 84 % info object call o m
{method m ::ObjMixin method} {method m ::ClassMixin method} {method m ::C method}
(tcl) 85 % oo::objdefine o {method m {} {puts object; next}}
(tcl) 86 % o m
ObjMixin
object
ClassMixin
C
(tcl) 87 % info object call o m
{method m ::ObjMixin method} {method m object method} {method m ::ClassMixin method} {method m ::C method}
Again, not sure if the bug is in the docs or the implementation
Referenced by1
ab635c8161[b9e1a3032e] Implement the documented method search order for TclOO. This corrects the relative positions of object-defined methods and class mixins. check-in2014-08-28 07:53:24
apnadkarni Ticket [b9e1a3032e]: 3 changes
[History diff]2014-07-31 14:15:41
dkfhtml2014-08-19 07:19:54
Oh, I remember this! Implementation bug (in the call chain builder) indeed. I can tell it has to be that way round, because otherwise there's no meaningful difference between class mixins and normal inheritance.
dkfhtml2014-08-19 07:31:17
And looking at the code, I can remember why I didn't get this right. Figuring out what should happen when you've got a class mixed into a class that is inherited by a class mixed into a class that we've instantiated (eek!) makes my head hurt.
dkf Ticket [b9e1a3032e]: 3 changes
[History diff]2014-08-19 07:31:42
dkfhtml2014-08-28 07:58:17
This should now be fixed. (The code to fix it is actually a fairly simple double traversal with flags tracking what we've seen, except for the case where we're dealing with filters in mixins, which is a bit brain-boggling.) Aggressive user testing encouraged.
Log in (anonymous is fine) to add a comment.