Atten: sswift

Miscellaneous Forums/General Discussion/Atten: sswift

Hey man, your Code archive entry:

EntityScaleX, EntityScaleY, EntityScaleZ.

You need to make the variables local, or they interfere with Global in the main code. Just a note, because it was confusing the hell outta me :D I had a Global called "scale", and it was changing it's value, hehe.

Which brings up the point... shouldn't variables used in a function be local be default?

Anyone other than sswift can answer that one btw :o)

I thought they were local by default. This is one of many reasons why I wouldn't go back to B3D. It all seemed so neat and nice at the time, but since learning the "correct"/"better" way to do it, I couldn't bear to go back to the amibiguities and lack of enforcement which led to so many silly bugs you couldn't track down.

Now I'm a happy BlitzMax programmer and I have far less ambiguous, unavoidable, hard to track down bugs. What can I say? The language got better, and I didn't.

No, variables in a function should not be local by default - how would that work?

Global PlayerLives

Function KillPlayer( )

PlayerLives = PlayerLives - 1

End Function


It's the same in BlitzMax - although with Strict on, if you use the function before the Global exists in your code, it will complain. However yes, sswifty should have used Local for maximum reusability (having written so many libraries, it's weird that he didn't).

That said, +100 for:

Now I'm a happy BlitzMax programmer and I have far less ambiguous, unavoidable, hard to track down bugs. What can I say? The language got better, and I didn't.


So true - coding in B3D (the language, not the engine) is almost physically painful now I've been exposed to better ways. Though I couldn't have made the transition to Bmax, C#, C++ or toying with lisp/ruby etc without what I learned in B3D, so I'll always have a lot of respect for it.

There is a lot of code in the archives that don't use 'Local' where they should (some of it probably mine). Anyone reading this would do lots of people a favour if they went thru and added them where necessary.

I'll get "ENAY" onto it - as soon as he surfaces.

I don't see any misisng local declarations. :-)

My only excuse is it was written in 2002 which wasn't all that long after I started coding in Blitz, and I'm much better about declaring my variables now. But you have no right to complain if you're still using globals for everything!

Well I guess you have some right to complain since we're talking about Blitz3D which doesn't let you limit the scope of variables to certain functions by putting them all in a type together like BlitzMax. I use Superstrict on everything I code now in Max. I was kind of forced to get into that habit because other users of my code might be doing it and I had to make sure all my code would work in that environment.