Псевдонимы - это команды, а не объекты. Однако для вызова (в отличие от изменения определений или создания подклассов и т. Д. c.) Вы можете установить псевдоним, указывающий на объект в другом интерпретаторе:
oo::class create Example {
variable count
method bar {} { return "this is [self] in the method bar, call [incr count]" }
}
Example create foo
interp create xyz
interp alias xyz foo {} foo
xyz eval {
puts [foo bar]
}
# this is ::foo in the method bar, call 1
Отдельные методы также могут go между интерпретаторами (с некоторыми ограничениями), если вы forward
вызываете метод для псевдонима, который пересекает границу интерпретатора. Это позволяет для всех видов махинаций.
oo::class create Example {
variable count
method bar {caller} { return "this is $caller in the method bar, call [incr count]" }
}
Example create foo
interp create xyz
interp alias xyz _magic_cmd_ {} foo bar
interp eval xyz {
oo::class create Example {
forward bar _magic_cmd_ pqr
}
Example create grill
grill bar
}
# this is pqr in the method bar, call 1