D design problem on platforms with <32 bit pointer width

Dom DiSc dominikus at scherkl.de
Sat Aug 19 10:43:59 UTC 2023


On Saturday, 19 August 2023 at 10:09:56 UTC, Dukc wrote:
> This is a request for comments. I've written it as a Git gist 
> as opposed to forum post because it's pretty long and may 
> warrant some editing at some point.
>
> Link: 
> https://gist.github.com/dukc/04ea4d4a248ff4709f89d5808f67a5fe
>
> Discussion can remain here though.

I hate those stupid promotion rules.
Every literal should be of the smallest type that can represent it
(e.g. 0..255 should be ubyte, 256..65535 should be ushort, etc., 
-1..-127 should be byte, -128..-32767 should be short, ...) and 
can be promoted to whatever is needed implicitly.
Yes, I think -128 should NOT be byte. this would stupid and error 
prone because abs(-128) cannot be byte. In fact 0x80 should be 
the NaN of byte, 0x8000 the NaN of short, etc. instead of 
exceptional negative values.
Also the operations should stay within the same type (largest of 
the involved operands), e.g. short+short = short.
Internally it may be best to work with the machine word size 
(whatever that is - could be even 8 bit) but should be truncated 
to the intended result if not otherwise stated (via cast).


More information about the Digitalmars-d mailing list