Joakim Christiansen wrote:I often find myself putting code into procedures to keep its variables within its own scope, but I tend to do this even for code that doesn't need to be inside a procedure just because of this!
So why not something as simple and nice as this:
Code: Select all
Define x,y,someValue=10
LocalScope
Define x,y ;should use local x,y instead of those defined outside
For x=0 To 320
For y=0 To 240
;whatever
Next
Next
Debug someValue ;should debug "10"
EndLocalScope
It would make my code flow more readable because I wouldn't have to relocate code as much...
I'm not sure what you are trying to illustrate?
If you don't want to overwrite x, y - good practice says use different names?
Wouldn't it be more efficient to restrict yourself to only using certain variable names as Temp/Garbage/throw-away variables? Like in your example when you need to loop something?
That's what I try to do I guess.. I also try to give my variables meaningful, but terse, names. It saves the simple a...z singletons for temp/trash type calculations, while keeping actual data in more clearly stored destinations..