|
2009-06-08
| ||
| 21:27 | • Closed ticket [2791586fff]: tailcall next weirdness plus 7 other changes artifact: c8f9b17e57 user: dkf | |
| 21:17 | • Ticket [2791586fff]: 4 changes artifact: 4037627316 user: dkf | |
| 21:03 | • Ticket [2791586fff]: 4 changes artifact: 96bebaf7d4 user: dkf | |
| 20:57 | • Ticket [2791586fff]: 4 changes artifact: 21b3218535 user: dkf | |
|
2009-05-22
| ||
| 04:34 | • Ticket [2791586fff]: 4 changes artifact: 26c8fc18cf user: dkf | |
|
2009-05-14
| ||
| 15:39 | • Ticket [2791586fff]: 1 change artifact: 6c0e6d10f9 user: dkf | |
| 08:38 | • New ticket [2791586fff]. artifact: 06857c01c9 user: dkf | |
[tailcall next] weirdness
Closed / Works For Me2791586fffffffffffffffffffffffffffffffffCreated 18 years agoUpdated 17 years ago
Descriptionplain2009-05-14 08:38:42
Something very odd is going on when you do [tailcall next]. Of course, it's an inherently odd thing to do anyway, but in that case it ought to error out in a sane way (similar to the way that [uplevel 1 next] is prohibited). This is not an issue for the standalone TclOO package.
% oo::class create foo {method bar {} {puts barbar}}
::foo
% foo create o
::o
% oo::objdefine o method bar {} {puts 1;tailcall next;puts 2}
% o bar
1
next may only be called from inside a method
% oo::objdefine o method foo {} {puts A;my bar;puts B}
% o foo
A
1
no next method implementation
% set errorInfo
no next method implementation
while executing
"next"
invoked from within
"my bar"
(object "::o" method "foo" line 1)
invoked from within
"o foo"
dkf Ticket [2791586fff]: 1 change
[History diff]2009-05-14 15:39:23
dkfplain2009-05-22 04:34:25
OK, within methods it's odd but somewhat plausible. Within constructors and destructors... eep!
dkfplain2009-06-08 20:57:42
within constructors, things can get odd but are at least logical...
% oo::class create foo {constructor {} {puts foo:con};method foo {} {puts foo:foo}}
::foo
% oo::class create bar {superclass foo; constructor {} {puts a;tailcall next;puts b};method foo {} {puts c;tailcall next;puts d}}
::bar
% oo::class create boo {superclass bar; constructor {} {puts p;next;puts q}}
::boo
% bar create 2
a
next may only be called from inside a method
% boo create 3
p
a
a
a
a
a
a
a
[ad infinitum]
dkfplain2009-06-08 21:03:32
moreover, with this test you can see that everything is processed correctly for constructors
% oo::class create foo {constructor {} {puts foo:con};method foo {} {puts foo:foo}}
::foo
% oo::class create bar {superclass foo; constructor {} {puts a; tailcall next; puts b};method foo {} {puts c; tailcall next; puts d}}
::bar
% oo::class create spong {superclass foo; constructor {} next; method foo {} {bar create ::z}}
::spong
% spong create x
foo:con
::x
% x foo
a
foo:foo
::z
dkfplain2009-06-08 21:17:26
(well; "correct" is still bizarre, but at least we're not crashing or losing objects)
dkfplain2009-06-08 21:27:17
allow_comments - 1
destructors similarly work sanely (well, within the bounds of sanity as defined in this odd context):
% oo::class create a {destructor {puts dead:a}}
% oo::class create b {destructor {puts dead:b1;next;puts dead:b2};superclass a}
% oo::class create c {destructor {puts dead:c1;next;tailcall next;puts dead:c2};superclass b}
% oo::class create d {destructor {puts dead:d1;next;puts dead:d2};superclass c}
% d create e
% e destroy
dead:d1
dead:c1
dead:b1
dead:a
dead:b2
dead:c1
dead:b1
dead:a
[...]
Ergo, not actually a bug in this area. Just a massive load of oddness.
Log in (anonymous is fine) to add a comment.