Tcl does have garbage collection (the exact implementation is undefined, whether it's reference counting or some other method). So no, you don't have to use unset to avoid memory leaks.
Tcl does have garbage collection (the exact implementation is undefined, whether it's reference counting or some other method). So no, you don't have to use unset to avoid memory leaks. I'm not sure why arrays would be considered bad.
You will have to provide references to such discussions to get specific comments.
This is one discussion : stackoverflow.com/questions/1323585/… – Newbie yesterday may be arrays and not bad just more cumbersome if going for multi dimensions than dict. However, I do not have anything that compares memory management of the two techniques. Which one is more efficient etc?– Newbie yesterday I don't think people normally worry about efficiency too much when programming in Tcl.
If you're using Tcl 8.4, there's no problem using arrays. – Greg Hewgill yesterday You only have to unset things that are of limited lifespan in a persistent context (e.g. , in the global namespace), but some things (e.g. , file handles, http tokens, objects) need manual deletion under normal circumstances. – Donal Fellows yesterday.
No, you do not need to free your local vars when you exit a procedure. They are automatically freed. This is the case most of the time, but there are exceptions (some extensions may require you to free things explicitly, and some packages, notably http, create tokens that need to be cleaned up) If you create large arrays in the global namespace, these will not be freed, because they can still be accessed.
There is no problem using arrays in tcl, but make sure you are using the right tool. In tcl an array is an "associative array", that is it is indexed by string. If you need a c-style array indexed by integer a plain old list may be better (you can pass it around by value) but you might consider it a little clumsier (subscripting is a command rather than a variable reference with a subkey).
Subscripting of lists is very fast, much faster than indexing into arrays (or dictionaries). – Donal Fellows yesterday.
Suppose I have a Tcl procedure. Inside the procedure I declare an array and add some data in it. I do some number crunching on that array.My question is before the procedure returns do I need to manually delete the array?
No. It will be deleted when the procedure returns (i.e. , its lifespan is bounded to that of the stack frame).
You may unset it earlier if you wish, which will free up its memory then, but you don't need to do that. Is using array in Tcl bad? I want to create Array of lists and while reading discussions on stack overflow people told to use dict for these kind of stuff but since I have Tcl 8.4 I can't.
What is the problem with arrays in Tcl? Arrays are absolutely fine in 8.4, so long as you remember that they are a collection that implements a map from arbitrary string keys to variables. Dicts are for cases where you want a value that holds a map from strings to arbitrary values.
(There's a dict extension for 8.4 somewhere about. ) You can use arrays to model matrices by choosing some character as a separator between the sub-indices (e.g. , a comma) and this technique has been used by many people to great effect. However it is more efficient to model them as lists of lists; the lset and multi-index lindex permit efficient update and lookup of elements of the resulting matrix.
(It is a bit verbose though.) If you're dealing with a lot of data, the improved efficiency can be very useful. (Sparse matrices may be better done as a Tcl array despite that. ) Also note that if you can upgrade to 8.5, a number of operations there are significantly faster (notably including testing for the presence of an element of an array with info exists).
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.