Dynamic Variables

Started by
29 comments, last by Andrew Nguyen 22 years, 3 months ago
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.
---START GEEK CODE BLOCK---GCS/M/S dpu s:+ a---- C++ UL(+) P(++) L+(+) E--- W++ N+ o K w(--) !O !M !V PS- PE+Y+ PGP+ t 5 X-- R tv+ b+ DI+ D G e* h! r-- !x ---END GEEK CODE BLOCK---
Advertisement
#define a (c / b)

ReactOS - an Open-source operating system compatible with Windows NT apps and drivers
I don''t know of any programming language that supports "Dynamic Varaibles".
But how can 5/5 be 0?
Minor thing, forget it.
---START GEEK CODE BLOCK---GCS/M/S dpu s:+ a---- C++ UL(+) P(++) L+(+) E--- W++ N+ o K w(--) !O !M !V PS- PE+Y+ PGP+ t 5 X-- R tv+ b+ DI+ D G e* h! r-- !x ---END GEEK CODE BLOCK---
Hmm... Interesting idea though. One could write a C++ class or something
It actually would be VERY useful in game programming (THe truth)
---START GEEK CODE BLOCK---GCS/M/S dpu s:+ a---- C++ UL(+) P(++) L+(+) E--- W++ N+ o K w(--) !O !M !V PS- PE+Y+ PGP+ t 5 X-- R tv+ b+ DI+ D G e* h! r-- !x ---END GEEK CODE BLOCK---
sounds alot like references
maybe
int &a = (c/b);
would work...not sure though
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
Maybe that class would accept a string operator and will recalculate again and again?
---START GEEK CODE BLOCK---GCS/M/S dpu s:+ a---- C++ UL(+) P(++) L+(+) E--- W++ N+ o K w(--) !O !M !V PS- PE+Y+ PGP+ t 5 X-- R tv+ b+ DI+ D G e* h! r-- !x ---END GEEK CODE BLOCK---
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!

This topic is closed to new replies.

Advertisement