Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

The roundtrip through the string rep can happen, but only if YOU treat the list as a string (more generally, as a non-list).

That's a hell of a thing to have to document, so I think it was appropriate to have the string conversion functions raise an error. When I worked on it, the code was running in Tcl 8.3 or 8.4, and I was able to reproduce the round trip through the string reliably with exactly the operations I described. I may have printed the list to the console as part of the test, and if that qualifies as "treating the list as a non-list" it pretty well proves the need to assume the worst. (It's also possible I was using older interfaces, even 10+ year old interfaces, since I kept my code consistent with the existing style in our software, but it's pretty harsh to say "your fault" if the interfaces for the most basic type in the language changed between versions 7 and 8, just saying.)



Oops, I did not mean to be harsh and apologize for coming across that way.

Tcl8 introduced the Tcl_Obj and a completely new api to deal with them. The old string-based interfaces were kept in place, because we value back compat a lot. They are flagged as deprecated in the manual pages and should only be used by legacy Tcl7 code, or when performance is known not to be an issue.

As to printing the list to the console: that should compute a string representation of the list object without discarding the representation as a list.




Consider applying for YC's Winter 2026 batch! Applications are open till Nov 10

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: