In the section "3.5.1 Arrays" of BitC specification (0.10+), it is
said that in type expression "(array T i)", "i" is an integer literal
of type word.

Does it mean that it is not possible to use an constant expression of
type word there?

If it is true, than it is goes against common practice in of avoiding
direct usage of magic numbers. It could cause engineering problems, if
different arrays should use related sizes.  If constant expression are
not allowed, these relations have to be tracked manually and updated
manually.

Compare readability and maintainability of:

(defstruct struct1 buffer1 : (array uint8 4096) )
-- the buffer should be able to contain two values buffer1 and four
additional bytes
(defstruct struct2 buffer2 : (array uint8 8196))

and:

(define buffer-size 4096 : word)
(defstruct struct1 buffer1 : (array uint8 buffer-size) )
-- the buffer should be able to contain two buffer1 and four additional bytes
(defstruct struct2 buffer2 : (array uint8 (+ (* buffer-size 2) 4))

I'm also interested why only bitfield type is allowed for "fill"
members of the "struct" type. If it is required to specify that 12
bytes are ignored, it is simpler to specify "(fill (array char 12))"
than  sequence of "(fill (bitfield uint64 64)) (fill (bitfield uint32
32))". It is possible to use "reservedXYZ" fields for this purpose,
but as I understand, "fill" has been introduced in order to avoid
usage of such fields in case of bitfields. Why not use it for other
types too?

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

Reply via email to