[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [RFC] Changing the unit of an offset

From: Jose E. Marchesi
Subject: Re: [RFC] Changing the unit of an offset
Date: Sat, 06 Feb 2021 18:06:51 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux)

>> But that gives us a magnitude, not an offset.  It would of course be
>> possible to write:
>>   (poke) (anoffset/#B)#B
>>   16#B
>> But that is too cumbersome.
>> So, what about having some short convenient syntax to change the unit of
>> an offset?
>> Note we would need to variants.  One equivalent to
>>   (offset/#UNIT)#UNIT
>> And the other equivalent to
>>   (offset/^#UNIT)#UNIT
>> The first uses truncating division, the second ceiling division.
>> Anybody has any suggestion for the syntax?
> First, note that it's more than "changing the unit", because — as you say —
> it may lose some bits.
> I therefore dislike an attribute-like syntax
>     offset'floor_as(#UNIT)
> and offset'ceil_as(#UNIT)
> and instead prefer see a syntax like the one used for casts:
>     offset floor_as #UNIT
> and offset ceil_as #UNIT
> or — if you can accommodate 3-character operators in the lexer —
>     offset /_* #UNIT
> and offset /^* UNIT
> Note that the latter is confusing, because /* is not an operator.

Hmm, for the operation to look like a cast makes sense, because after
all it _is_ a cast:

   offset as offset<int<32>,#B>  (offset being of type
                                  offset<int<32>,#b> for example)

But, the offset above performs truncation only.

If we were to have an alternate shoter syntax for that offset, what
about this:


reply via email to

[Prev in Thread] Current Thread [Next in Thread]