2 TomToad
To protect list from GC, if u don't want use it as regular, is declare it as global var. See my first sample. Or use trick below.
2 Azathoth
Then you don't understand errors in code by Otus. I showed it already. Or u don't understand what 'l' don't use in code after "Local link:TLink = l.FirstLink()"? And any references to list not exist after this?
Well how about this code, when 'l' REALLY still reference until end of program:
Just write right and clean code and all be OK ;P
Use Global for global variables and don't declare global variables as local.
To protect list from GC, if u don't want use it as regular, is declare it as global var. See my first sample. Or use trick below.
2 Azathoth
Then you don't understand errors in code by Otus. I showed it already. Or u don't understand what 'l' don't use in code after "Local link:TLink = l.FirstLink()"? And any references to list not exist after this?
Well how about this code, when 'l' REALLY still reference until end of program:
SuperStrict Framework BRL.StandardIO Import BRL.LinkedList Local l:TList = New TList l.AddLast "Hello " l.AddLast "World" Local link:TLink = l.FirstLink(), s:String For Local i:Int = 1 To 1000000 s = String(link.Value()) link = link.NextLink() s:+ String(link.Value()) link = link.PrevLink() Print s Next Print l.count();
Just write right and clean code and all be OK ;P
Use Global for global variables and don't declare global variables as local.