[foreign-memaccess] layouts, bits and bytes: call for bikeshed :-)
Paul Sandoz
paul.sandoz at oracle.com
Fri May 15 16:12:06 UTC 2020
It’s hard to have a strong opinion on this one :-)
Arguably a single unit for construction may mean less errors. Querying in different units seems useful for interoperation, esp. since segments are in units of bytes.
Maybe wait and see based on usage? (Perhaps that is in part what motivated the email?)
They can always be added later on.
Paul.
> On May 15, 2020, at 7:16 AM, Maurizio Cimadamore <maurizio.cimadamore at oracle.com> wrote:
>
> Hi,
> currently the MemoryLayout API is defined internally in terms of bits; this is for a reason, as we want to be able to use layouts for sub-bytes entities (e.g. bitfields). That said, the API is quite liberal in allowing the user to interact with it either in bits or bytes. For instance both layout size and alignment can be retrieved in the preferred format.
>
> There's an exception to this rule: layout creation. We have two factories, namely:
>
> MemoryLayout::ofValueBits
> MemoryLayout::ofPaddingBits
>
> Which do not provide the corresponding XYZByte overloads.
>
> If we were to add such overloads, the next hurdle would be the set of constants in MemoryLayouts, where we have e.g.
>
> ValueLayout BITS_8_LE
> ValueLayout BITS_16_LE
> ...
>
> Perhaps it would make sense to expose these in bytes too as well as bits, and add:
>
> ValueLayout BYTES_1_LE
> ValueLayout BYTES_2_LE
> ...
>
>
> How do people feel about these changes? Useful? Confusing?
>
> Let's paint this bikeshed :-)
>
> Cheers
> Maurizio
>
More information about the panama-dev
mailing list