Re: From Atom to Binary Sequence

new topic     » goto parent     » topic index » view thread      » older message » newer message

There has been some discussion on this topic on the developers' list on the topic of how should bitwise functions including conversion routines should work.

As another has pointed out, using positive numbers is a nicer way of looking at bit-vectors. Whenever we have a flags value with boolean bitwise operations, we are really using a register as a bit-vector. There are limits of 32-bits which is normally enough if you ever need more than 32 you can change this:

--character attributes 
constant UGLY=1, STRONG=2, HAPPY=4, ... 

to this:

-- character attributes 
constant flag_count=40 
constant UGLY=int_to_bits(1,flag_count), STRONG=int_to_bits(2,flag_count), ... 

The bitwise operations will work on these sequences component-wise, so you can still use for example or_bits(UGLY,STRONG) as you would with the numbers. It is wordy and inefficient as hell, but you are not limited to 32 bits.

Shawn

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu