> On Sat, 2007-02-24 at 19:28 -0500, Swaroop Sridhar wrote:
>> * The fields within the when clauses of all constructor forms must 
>> uniquely distinguish all constructible values of the union. The compiler 
>> will not introduce any more tag bits for any defrepr value.

Should the unique discrimination be by name or by offset?

That is, is the following repr legal?

(defrepr repr
    (C1  i: (bitfield uint32 2)
         j: (bitfield uint32 30) (where (i 0))
    (C1  k: (bitfield uint32 2)
         l: (bitfield uint32 20)
         m: (bitfield uint32 20) (where (k 1))
)

where i/k is the discriminator (bit-positions agree).

Or, is it required to be written as:

(defrepr repr
    (C1  i: (bitfield uint32 2)
         j: (bitfield uint32 30) (where (i 0))
    (C1  i: (bitfield uint32 2)
         l: (bitfield uint32 20)
         m: (bitfield uint32 20) (where (i 1))
)

So that where clauses agree by name?

The second case is better from the point of view of error reporting.
For example: we can show a set of (field names, value) pairs that cause 
ambiguity. Is this power sufficient?

Otherwise, we would have to show (offset-value) pairs or a long 
bit-vector that cannot be disambiguated.

In either case, I don't think the following should be legal:

(defrepr repr
    (C1  (reserved (bitfield uint32 30) 0)
         j: (bitfield uint32 30))
    (C1  k: (bitfield uint32 2)
         l: (bitfield uint32 20)
         m: (bitfield uint32 20) (where (k 1))
)

even though values are unique.

Swaroop.


_______________________________________________
bitc-dev mailing list
[email protected]
http://www.coyotos.org/mailman/listinfo/bitc-dev

Reply via email to