#### Archived

This topic is now archived and is closed to further replies.

# Dynamic Variables

This topic is 6018 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

I''m thinking, is there a Dynamic Varible available? No.was the answer. Now, I have to say, they are useful. What is a dynamic variable you may ask, well, if i said: dynamic int a and a = (c/b), then if c and b bothe equaled 5, a would be 0 now, the computer only processess that once, but what if b or c changed? Well, with a dynamic variable, a would be constantly recalculated if b or c were constantly recalculated too.

##### Share on other sites
#define a (c / b)

##### Share on other sites
I don''t know of any programming language that supports "Dynamic Varaibles".
But how can 5/5 be 0?

##### Share on other sites
Minor thing, forget it.

##### Share on other sites
Hmm... Interesting idea though. One could write a C++ class or something

##### Share on other sites
It actually would be VERY useful in game programming (THe truth)

##### Share on other sites
sounds alot like references
maybe
int &a = (c/b);
would work...not sure though

##### Share on other sites
quote:
Original post by barazor
sounds alot like references
maybe
int &a = (c/b);
would work...not sure though

Blahh.. Maybe! I've got to test this out!

Edited by - MindFlayer on December 31, 2001 4:47:27 PM

##### Share on other sites
Maybe that class would accept a string operator and will recalculate again and again?

##### Share on other sites
Maybe the only viable solution so far is Martee''s #define?

Your class would need to create a thread and periodically poll the values of variables it was assigned to monitor - useless overhead. If the variable was a symbolic alias (meaning that it was replaced by the actual values at compile time), then it would work but would introduce some new problems.

I think it''s easier to simply notify any "watcher" variables whenever code modifies a variable''s value.

[ GDNet Start Here | GDNet FAQ | MS RTFM | STL | Google ]
Thanks to Kylotan for the idea!

1. 1
2. 2
3. 3
4. 4
5. 5
Rutin
18

• 11
• 12
• 9
• 12
• 37
• ### Forum Statistics

• Total Topics
631420
• Total Posts
2999990
×