Bitwise comparisons

New releases and general discussions.

Post » Sun Feb 01, 2009 5:27 pm

Bitwise operations can be very useful at times, particularly when dealing with long lists of flags. It feels like such a waste to me to designate 30 private variables, each of which only needs to check for being a 1 or a 0 anyway. Perhaps allowing a boolean type would also satisfy me, but there's just something elegant about a nice Bitwise OR.
B
2
G
3
Posts: 71
Reputation: 992

Post » Sun Feb 01, 2009 5:52 pm

You could use for a 'for' or 'repeat x times' loop to go through the variables and check them, if they are all named something like 'Variable5', 'Variable28' or something.

One thing we could add though is a 'For each private variable', which may help here.
B
3
S
2
G
5
Posts: 1,777
Reputation: 5,529

Post » Sun Feb 01, 2009 7:23 pm

I decided to use hash tables for that.
B
62
S
21
G
12
Posts: 1,910
Reputation: 13,155

Post » Sun Feb 01, 2009 7:57 pm

Add one to the list of people who doesn't like a bunch of global variables hanging around. I don't know, it just seems messy. (IMHO)
B
3
S
2
G
4
Posts: 271
Reputation: 2,017

Post » Sun Feb 01, 2009 8:36 pm

I never got to hash tables in my classes. How do they work?

Is implementing bitwise operations really that tricky? (not a rhetorical question)
B
2
G
3
Posts: 71
Reputation: 992

Post » Sun Feb 01, 2009 8:52 pm

Getting rid of bugs is now at higher priority than adding new functionalities.

On the other hand I think that most of us have his/her own techniques when dealing with data. If everyone's wishes were fulfilled, you'll get your bitwise operations, but also 10 other techniques for handling values (flags system/stacks/queues/lists/dictionaries/pointers/some weird data management templates used by 1 person on the world/other stuff), what would make Construct messy. Simplicity is key for success here.
B
6
S
3
G
6
Posts: 219
Reputation: 3,013


Return to Construct Classic Discussion

Who is online

Users browsing this forum: No registered users and 0 guests