4 ms·
> ...the above is actually somewhat problematic, because to hold a reference to the C struct, you have to then manually free it later, losing some of the benefi
by bch 11y ago
> ...the above is actually somewhat problematic, because to hold a reference to the C struct, you have to then manually free it later, losing some of the benefits of a language with automatic memory management.
I usually frame the data as clientData passed to a managing command (i.e. custom built first-class command), with appropriate allocation/deallocation. As often as not, I'm creating two commands: an anonymous reference template, and a command-creating-command that will instantiate instances of the "anonymous reference template". Then I can create an arbitrary number of arbitrarily named commands that pack and process their data, including freeing on destruction.
To the uninitiated, this sounds like object-oriented programming, which is arguably true, but doesn't automatically come with subclassing, inheritance, etc, etc. Tcl does have first class objects, but what I'm describing here isn't them.
- srean 11y agoQuite curious to take a look if you have anything available for the public eye.