Lot of wrong things said on this topic...
Types are not local at all, but can't be considered as global. Types are not a way to declare variables.
Only things local in your codes are the variables used to point to the type.
The types themself still remain somewhere in the memory.
And "this is not a memory holl, this is a feature " ( Bill Gates )
this second code show you can access any type everywhere you want.
+> absolutely no local
I always use object/handle now when passing types...
I do the same, but, i only do it for librarys functions => just for external user that will prefer deal with integer variable rather than with types
For private function, I prefer do it with full type declaration
+> It's faster and there is less to check to be sure the specified object exists.
Types are not local at all, but can't be considered as global. Types are not a way to declare variables.
Only things local in your codes are the variables used to point to the type.
The types themself still remain somewhere in the memory.
And "this is not a memory holl, this is a feature " ( Bill Gates )
Type TType Field v End Type ; Making list of instances For n = 1 To 10 NewTType(n) Next ; Access the last TType => Of course, as theirs I made come from behind a function, they are locally, so Last TType=null. t.TType=Last TType Print t\v ; Now, we can say one thing... ; => Types are not like a simple local. WaitKey End ; return nothing ! Function NewTType(val) Local t.ttype=New ttype t\v=val ; Oooo it is a local, so as it is said on BlitzBasic.com, i assume it will be deleted ... mmmm.... End Function
this second code show you can access any type everywhere you want.
+> absolutely no local
Type TType Field v End Type For n = 1 To 10 NewTType(n) Next PrintFirst() WaitKey:End Function NewTType(val):Local t.ttype=New ttype:t\v=val:End Function Function PrintFirst() :t.ttype=First ttype:Print t\v:End Function
I always use object/handle now when passing types...
I do the same, but, i only do it for librarys functions => just for external user that will prefer deal with integer variable rather than with types
For private function, I prefer do it with full type declaration
+> It's faster and there is less to check to be sure the specified object exists.