itcl::scope
の指定されたメンバ変数の完全な名前を返します$this
。
itcl::scope
同じクラスの別のオブジェクト ( ではなく)を呼び出すにはどうすればよい$this
ですか?
これが回避策です。
itcl::class dummy {
variable m_data
method function { other } {
if { [itcl::is object -class dummy $other] } {
error "Invalid argument."
}
set name "@itcl $other [$other info variable m_data -name]"
# OR
set name [lreplace [itcl::scope m_data] 1 1 $other]
puts "==== this is the name of m_data of of object $other: $name"
}
}
しかし、控えめに言っても、これは醜いです。
必要なものを返す必要があると思います$other info variable m_data -name
が、オブジェクトのコンテキストが省略されているだけです。