On 03/29/2011 11:31 PM, thorsten.i.r...@jyu.fi wrote: > for (var i =0; i< 30; i=i+1) # number of objects is 30 > > is superior to > > var number_of_objects = 30; > for (var i = 0; i < number_of_objects; i = i+1)
No it isn't. Variable references aren't garbage (well, they aren't heap blocks, though they do get traced). The things they point to are garbage, and a number isn't a reference in Nasal. The "30" in the second example gets stored (as a double) directly in the hash record in place of the pointer that would be there if it were a reference. The "var" syntax has no meaning as far as allocation. It's about scoping, it says "make this a local variable in the current function no matter what outer scope it might also be in". The operations in Nasal that create heap blocks/garbage are: 1. String composition with the "." operator 2. Vector creation with a "[...]" expression 3. Hash creation with a "{...}" expression 4. Function calls (which create a hash for the namespace) 5. Closure binding with a "func ..." expression. I believe that's all of it, though I may have forgotten something. Andy ------------------------------------------------------------------------------ Create and publish websites with WebMatrix Use the most popular FREE web apps or write code yourself; WebMatrix provides all the features you need to develop and publish your website. http://p.sf.net/sfu/ms-webmatrix-sf _______________________________________________ Flightgear-devel mailing list Flightgear-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/flightgear-devel