Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Newcomers DBPro Corner / Declaring Variables

Author
Message
JerBil
20
Years of Service
User Offline
Joined: 8th May 2004
Location: Somewhere along the Z axis...
Posted: 15th Sep 2004 11:05
Question:
Is there any benefit to declaring variables, even if they are "empty" before the main program loop? I often throw a variable in somewhere as I go. This is actually a compiler question, I guess.

-JerBil
Dot Merix
21
Years of Service
User Offline
Joined: 15th Oct 2003
Location: Canada
Posted: 15th Sep 2004 11:10
If it was c++, then yes.. it can make a difference.

In darkbasic, i havent really found any reason to, besides making your code look a little nicer..

ie..

playerone_obj = 1
load object "playerone.x",playerone_obj

In this sense, it's easier to know what's going on with your code instead of having numbers

- Merix
the_winch
21
Years of Service
User Offline
Joined: 1st Feb 2003
Location: Oxford, UK
Posted: 15th Sep 2004 11:16
I guess if they ever get around to adding forced variable declaration you won't have to change a lot of code to take advantage or it. Also the $ and # characters often make variable names more difficult to type.


it's cool to hate
Indian Homie G
20
Years of Service
User Offline
Joined: 23rd Jan 2004
Location: San Jose, CA
Posted: 15th Sep 2004 11:43
Unless it doesnt start out at 0, then there's no big difference really, on the contrary, it might actually HELP a bit. Because if you only "define" the variable when you're using it, its one less variable for the compiler to keep track of .

Cheers!

AMD Athlon XP 3000+, S3 Deltachrome s8, 512 PC3200 RAM, 160 GB HD
JerBil
20
Years of Service
User Offline
Joined: 8th May 2004
Location: Somewhere along the Z axis...
Posted: 16th Sep 2004 00:29
Thanks, guys.

Login to post a reply

Server time is: 2024-11-27 09:46:00
Your offset time is: 2024-11-27 09:46:00