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

:) If you are using Tcl7 (Tcl8 is 10+ years old) or the OLD string interfaces on Tcl8, things go through the string rep and will be dog slow - your fault. Tcl's lists, for instance, are maintained internally as C arrays of pointers to the element objects. The roundtrip through the string rep can happen, but only if YOU treat the list as a string (more generally, as a non-list).

As to "deep changes to an old language": Tcl is actively maintained and still evolving. Tcl8.5 introduced anonymous functions among many other changes; Tcl8.6 (in beta) has a completely new engine (somewhat similar to py's stackless), coroutines and tailcalls, a builtin OO system, and many other enhancements.



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.




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

Search: