On 15/07/2014 10:32 PM, Jonathan S. Shapiro wrote:
> So would it be fair to say that you prefer the Ada approach to layout 
> specification (separate from the datatype) over the C approach where 
> field types have a defined type and alignment?

I haven't had to worry about alignment too much, but it certainly seems 
like less cognitive overhead to specify such properties separately and 
have them checked, instead of having to do the arithmetic in my head 
given the type structure.

It seems such a facility would be needed anyway if the compiler will be 
able to produce different declarative layouts, ie. packed structures 
[1]. I think Ada has a decent approach here, with their clause syntax 
for declaring all sorts of type properties, including sizes, alignments, 
storage size, bit order, etc. [2]

It's sub-optimal in some ways though. Ideally, a language would permit 
declarative numeric ranges as in Ada, but to arbitrary precision and 
unboxed. Then the clause syntax would allow you to override the default 
storage and alignment properties for such unboxed fields. This would 
eliminate the unnecessary proliferation of primitive numeric types.

Slightly less ideal, but still good is something like LLVM's integral 
type, ie. int(N)/uint(N), where N is the number of bits. This might be 
simpler for you since it sounds like you're already leveraging kinding 
for safe vector indexing.

Sandro

[1] https://gcc.gnu.org/onlinedocs/gnat_rm/Pragma-Pack-for-Arrays.html
[2] http://docs.adacore.com/gnat-unw-docs/html/gnat_rm_9.html

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

Reply via email to