Posts: 3,616
Threads: 287
Joined: Jan 2003
Just wondering...are they simply variables that QB makes sure you don't touch, or are they just symbolic, and all occurences are replaced at compile time (like C's #define)?
f only life let you press CTRL-Z.
--------------------------------------
Freebasic is like QB, except it doesn't suck.
Posts: 1,752
Threads: 21
Joined: Jun 2002
Posts: 3,616
Threads: 287
Joined: Jan 2003
Good. Memory-resident constants are slower.
f only life let you press CTRL-Z.
--------------------------------------
Freebasic is like QB, except it doesn't suck.
Posts: 3,343
Threads: 83
Joined: Mar 2003
I think more importantly, in such a memory-starved language as QB, memory-resident constants would take up memory
Posts: 3,616
Threads: 287
Joined: Jan 2003
That too. :wink:
That's especially true with RPGs and such - Operation Pong uses a hundred constants, just to keep track of player frames and directions, and tiles.
f only life let you press CTRL-Z.
--------------------------------------
Freebasic is like QB, except it doesn't suck.
Posts: 3,343
Threads: 83
Joined: Mar 2003
Well, they're useful anyway. I wonder - if constants are just swapped, would it be an advantage to have a routine that runs just before a program is compiled that got swapped all the constants with their values and removed the CONST lines? So, like the way that QBMCX gets metas out and passes switches to the compiler, this program would strip consts out and put the prog in a temp file and get the compiler to compile that. Would that save a few bytes of memory?
Posts: 3,616
Threads: 287
Joined: Jan 2003
Not worth the trouble, IMHO - the only memory that would be saved is at compile-time. You don't usually have to care about that - only runtime should be a worry. If constants were just protected variables, then you'd have reason to tear your hair out. :wink:
f only life let you press CTRL-Z.
--------------------------------------
Freebasic is like QB, except it doesn't suck.
Posts: 3,343
Threads: 83
Joined: Mar 2003
Oh well, if anyone needs some more mem at compile time they'll know how to do it...
Posts: 3,522
Threads: 189
Joined: Dec 2003
How come:
CONST nana=90
a=a+nana
is faster then:
a=a+90
Because it is, place it in a loop and see for yourself.
Anyone?
Posts: 451
Threads: 16
Joined: Feb 2003
It's interesting to note, string constants are memory-resident and loaded into the variables and what-not at load-time, not compile-time. It's only numeric constants that are changed at compile-time.
Life is like a box of chocolates', hrm, WTF, no it isn't, more like, 'life is like a steaming pile of horse crap.'