Other integral literals?

spir denis.spir at gmail.com
Sun Mar 20 11:37:45 PDT 2011


On 03/20/2011 04:40 PM, bearophile wrote:
> Do you ever desire literals for byte, ubyte, short and ushort integrals (beside the currently present for int, uint, long, ulong that are 10, 10U, 10L, 10UL)?
>
> Because of the more strict typing of templates in some situations I have had to write things like:
>
> cast(ubyte)100
>
> Possible literals for byte, ubyte, short and ushort integrals (the byte ones aren't great):
> 10Y
> 10UY
> 10S
> 10US
>
> Are similar suffixes useful enough to have?

I would support this gratefully. I find it a big weakness of D that its 
literals do not map to a type.

As for precise morphology, I'd prefere
* instead of cryptic suffixes like 'Y' or 'S', numerous languages simply write 
the size : 8, 16, 32, 64: much nicer! A better idea would be to count the size 
in bytes: 1, 2, 4, 8.
* else, use lowercase suffixes in std, because digits are full height (so that 
the suffix is more clearly told apart)
* for the same reason, hex literals should use uppercase digits in std and '0x' 
prefix
* ideally, I would use the sign to tell signed types apart (1 is unsigned, +1 
is signed)
* get rid of "1." and ".1" horrors!
* get rif of 01 octal bug!

Denis
-- 
_________________
vita es estrany
spir.wikidot.com



More information about the Digitalmars-d-learn mailing list