Tcl_Concat(3tcl)

πŸ“¦
version 9.0.4 Β· 2 versions
, in debian trixie, ubuntu questing, ubuntu resolute, ubuntu stonking

✨ NAME ✨

Tcl_Concat β€” bestie, it concatenates a whole collection of strings πŸ’–


πŸŽ€ SYNOPSIS πŸŽ€

#include <tcl.h>

const char *
Tcl_Concat(argc, argv)

🌸 ARGUMENTS 🌸

  • Tcl_Size argc (in) β€” the number of strings, periodt. That's the count. πŸ”’
  • const char *const argv[] (in) β€” the array of strings you want to smoosh together. It must have argc entries, no cap. If it doesn't, that's on you bestie πŸ™ˆ

πŸ’… DESCRIPTION πŸ’…

So Tcl_Concat is a lil utility procedure that several of the Tcl commands literally use internally. Give it a collection of strings and it concatenates them all into one single string, with the original strings separated by spaces. Iconic behaviour, honestly.

Heads up though: this procedure behaves differently than Tcl_Merge, because the arguments are just simply concatenated β€” no effort is made to ensure proper list structure. Not a single one. It's giving "I'm just gluing these together, don't ask questions" πŸ’€

That said, in most common usage the arguments will all be proper lists themselves, and if that's true, then the result will also have proper list structure. So it works out 🫢

Tcl_Concat also eliminates leading and trailing white space as it copies strings from argv to the result. And if an element of argv consists of nothing but white space? Then that string is ignored entirely. Gone. Not invited. This white-space removal was added to make the output of the concat command cleaner-looking β€” and honestly, the way that it just ✨ tidies ✨ everything up is so satisfying.

The result string is dynamically allocated using Tcl_Alloc, so the caller must eventually release the space by calling Tcl_Free. Bestie. Do not forget. Memory leaks are not the vibe πŸ”₯


πŸ¦‹ SEE ALSO πŸ¦‹

  • Tcl_ConcatObj

πŸ‘‘ KEYWORDS πŸ‘‘

concatenate, strings


okay so that's the whole page, no cap β€” written for the Tcl Library Procedures manual, Tcl 7.5, and it's Tcl_Concat(3tcl) if you need to cite your sources πŸ“š πŸ’œβœ¨

πŸ“¦ where this page comes from