|
2008-11-01
| ||
| 07:38 | • Closed ticket [2200824fff]: awkward namespace behaviour plus 6 other changes artifact: dec6801251 user: dkf | |
| 05:11 | • Ticket [2200824fff]: 5 changes artifact: 0c16f613c6 user: dkf | |
|
2008-10-31
| ||
| 22:15 | • Ticket [2200824fff]: 4 changes artifact: 8f935815f0 user: dkf | |
|
2008-10-27
| ||
| 22:44 | • Ticket [2200824fff]: 1 change artifact: 0ff8c44160 user: dkf | |
| 13:55 | • New ticket [2200824fff]. artifact: d326098e58 user: cnassau | |
awkward namespace behaviour
Closed / Fixed2200824fffffffffffffffffffffffffffffffffCreated 18 years agoUpdated 18 years ago
Descriptionplain2008-10-27 13:55:12
I've been playing around with the [otherwise wonderful] new oo package and stumbled across some namespace issues that I find rather inconvenient.
The following code works as it stands, but breaks if it is moved into a namespace:
oo::class create fruit {}
oo::class create banana {
superclass fruit
}
If this is evaluated in namespace mynsp the superclass statement needs to be changed:
namespace eval mynsp {
oo::class create fruit {}
oo::class create banana {
# superclass fruit ;# <- should work
superclass mynsp::fruit ;# does work
}
}
I currently see no [non-convoluted] way to avoid the hardcoded reference to the mynsp-namespace in this superclass statement.
The reason seems to be that oo::class evaluates its script in the oo::define namespace. Wouldn't it be better to extend the "namespace path" of oo::define during the execution of the definer script with the namespace path of the current namespace?
Variable resolution is troubled by the same dilemma: the code
namespace eval mynsp {
set bar baz
oo::class create foo {
method $bar args {}
}
}
fails most of the time, because $bar currently resolves to $::bar rather than $mynsp::bar.
I would most humbly suggest to review these resolution rules again.
dkf Ticket [2200824fff]: 1 change
[History diff]2008-10-27 22:44:00
dkfplain2008-10-31 22:15:59
Agreed that this is an issue. Not yet quite sure how to fix neatly. Hmmm....
dkfplain2008-11-01 05:11:27
Fixed in Tcl HEAD. Needs backport. Note that the fix for this is quite involved, because it otherwise breaks the error traces out of class constructors. Fixing *that* requires defining a command that is a combination of [uplevel] and [catch] and which also suppresses errors a bit more too. Tricky stuff!
dkfplain2008-11-01 07:38:24
Backported
Log in (anonymous is fine) to add a comment.