digitalmars.D.learn - Other integral literals?
- bearophile (11/11) Mar 20 2011 Do you ever desire literals for byte, ubyte, short and ushort integrals ...
- Kagamin (1/1) Mar 20 2011 http://d.puremagic.com/issues/show_bug.cgi?id=4870
- spir (20/29) Mar 20 2011 I would support this gratefully. I find it a big weakness of D that its
- Simen kjaeraas (6/9) Mar 20 2011 I hope you messed that one up. An unadorned int literal should be signed...
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? Bye, bearophile
Mar 20 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
Mar 20 2011
On Sun, 20 Mar 2011 19:37:45 +0100, spir <denis.spir gmail.com> wrote:* ideally, I would use the sign to tell signed types apart (1 is unsigned, +1 is signed)I hope you messed that one up. An unadorned int literal should be signed. Period.* get rid of 01 octal bug!Oh gods, yes. -- Simen
Mar 20 2011