On May 4, 2008, at 10:24 PM, andrey mirtchovski wrote:

Set for the next release: bit arrays.

"I'd use plan 9 before i'd use bitfields" -- pjw

I'm aware of that quote. The design of bit arrays will be totally different from the design of bitfields. They are true arrays that can be used in an implementation-independent manner. Given

        b: 32 bits
        b[0] := 4

the compiler will determine whether b[0] is at the far left or far right of the binary version of that value. This means you can have code, theoretically, like

        function getlong: 32 bits
                b: 32 bits
                b[31..24] := getchar - '0'
                b[23..16] := getchar - '0'
                b[15..8] := getchar - '0'
                b[7..0] := getchar - '0'
                return b

and then use getlong as follows:

        x: 32 bits = getlong
        if x = 400 then
                { ... }

This is a severe blow to bit fields.

No, I'm not doing a school assignment. This is more of a hobby project.


Reply via email to