Skip to content
Tcl Source Code View Ticket
Login

View Ticket

2024-11-21
07:40 • Ticket [4bbb308ab2] trace causes generation of string representation of "co... artifact: 8b2792f7c5 user: pooryorick
2018-06-20
13:17 • Ticket [4bbb308ab2]: 3 changes artifact: de06b65b40 user: pooryorick
13:17 • Ticket [4bbb308ab2]: 3 changes artifact: 634d9c3dc2 user: pooryorick
2018-04-30
12:19 • Ticket [4bbb308ab2]: 3 changes artifact: 381b28d9d3 user: dgp
12:04 • Ticket [4bbb308ab2]: 3 changes artifact: 456e458592 user: dgp
10:54 • Ticket [4bbb308ab2]: 3 changes artifact: 0a08df80c7 user: sebres
2018-04-28
13:42 • Ticket [4bbb308ab2]: 3 changes artifact: 0a3d4dd3a0 user: pooryorick
13:42 • New ticket [4bbb308ab2]. artifact: b59dba9d46 user: pooryorick

trace causes generation of string representation of "commandPrefix" argument

Open4bbb308ab26fe4aea344f1c0f744ccbef3f0543fCreated 9 years agoUpdated 2 years ago
Descriptionwiki2018-04-28 13:42:26
When a pure list is passed as the commandPrefix argument, the string representation of that list is generated:
	proc p1 {list args} {
		puts [list in . p1 [::tcl::unsupported::representation $list]]
	}

	set list [list one two three]
	puts [list initial [::tcl::unsupported::representation $list]]
	set var1 {}
	trace add variable var1 read [list p1 $list]
	set list [list p1 one two three]
	set var1
	

Output:

	initial {value is a list with a refcount of 3, object pointer at 0x55f4052f7ad8, internal representation 0x55f4052db288:(nil), no string representation}
	in . p1 {value is a pure string with a refcount of 3, object pointer at 0x55f4051a8aa8, string representation "one two three"}
	
pooryorick Ticket [4bbb308ab2]: 3 changes [History diff]2018-04-28 13:42:54
sebreswiki2018-04-30 10:54:02

This going to concat by trace add (which currently does not differentiate between canonical and not-canonocal arguments):

unset -nocomplain var1
proc p1 {list args} {
  puts "in p1:\t\t[::tcl::unsupported::representation $list]"
} 
set list [list one two three]; set var1 {}
puts "init:\t\t[::tcl::unsupported::representation $list]"
trace add variable var1 read [list p1 $list]
puts "trace added:\t[::tcl::unsupported::representation $list]"
set var1
Still worse is IMHO the duplication with resulting loss of real object type (it will be to pure string inside the call of trace).

I found this several years ago and fixed already in my own branches.
I'm sure I had already a ticket for this, but can not find it anymore.

Anyway I'll push a branch next week (for >= 8.5) which closes it.

dgpplain2018-04-30 12:04:46
Likely related to 

https://core.tcl-lang.org/tcl/tktview?name=3485833

and the branch bug-3485833
dgpplain2018-04-30 12:19:21
Strictly speaking this is not a bug. String generation is a
functionally valid thing Tcl or extensions may do.

That said, it can be unwelcome, and any changes in the innards
of [trace] that reduce the necessity of string generation seem
like a good idea.
pooryorick Ticket [4bbb308ab2]: 3 changes [History diff]2018-06-20 13:17:22
pooryorick Ticket [4bbb308ab2]: 3 changes [History diff]2018-06-20 13:17:51
pooryorick Ticket [4bbb308ab2]: 3 changes [History diff]2024-11-21 07:40:00
Log in (anonymous is fine) to add a comment.