これらの値は、おそらく文字列として開始されます(完全にではありません。これは、リテラル共有の可能性があるためです)。最後に、tcl::unsupported::representation
コマンドが8.6のみであり、が決してに変更されているオブジェクトが変更されている場合、その最初の行に;format x
を入れて、驚かないようにしますコンバージョン)。
% set value [list "12" 14 2a "1a"];format x
x
% tcl::unsupported::representation [lindex $value 0]
value is a pure string with a refcount of 2, object pointer at 0x100874070, string representation "12"
% tcl::unsupported::representation [lindex $value 1]
value is a pure string with a refcount of 2, object pointer at 0x1008741c0, string representation "14"
% tcl::unsupported::representation [lindex $value 2]
value is a pure string with a refcount of 2, object pointer at 0x100874c40, string representation "2a"
% tcl::unsupported::representation [lindex $value 3]
value is a pure string with a refcount of 2, object pointer at 0x1008743d0, string representation "1a"
% tcl::unsupported::representation $value
value is a list with a refcount of 4, object pointer at 0x100874910, internal representation 0x1008eb050:0x0, string representation "12 14 2a 1a"
はい、これらの値はほとんど同じです。それらのいずれかの内部表現はなく、それぞれが使用している文字列表現は、3バイト長(各文字に1つ、終端NULバイトに1つ)に割り当てられたバッファです。しかし、リスト自体には、要求されていないにもかかわらず文字列表現(内部リスト担当者と同様)があります。これは、リテラルのリストを使用しているためで、Tclのコンパイラは、それを通常は正しいものとして1つのリテラルに最適化します。
コマンドが引数を受け取る前に引用符が取り除かれているので、私はそうしたいと思います。 –