'int' is enough for 'length' to migrate code from x86 to x64

ketmar via Digitalmars-d digitalmars-d at puremagic.com
Wed Nov 19 05:21:47 PST 2014


On Wed, 19 Nov 2014 10:03:34 +0000
Don via Digitalmars-d <digitalmars-d at puremagic.com> wrote:

> No! No! No!  This is completely wrong. Unsigned does not mean 
> "positive". It means "no sign", and therefore "wrapping 
> semantics".
> eg length - 4 > 0, if length is 2.
> 
> Weird consequence: using subtraction with an unsigned type is 
> nearly always a bug.
negative length is a bug too. and it doesn't matter what king of
integer is used if you didn't fail your sanity checks.

> I wish D hadn't called unsigned integers 'uint'. They should have 
> been called '__uint' or something. They should look ugly. You 
> need a very, very good reason to use an unsigned type.
> 
> We have a builtin type that is deadly but seductive.
you just named all of built-in types. ah, and rename all keywords too,
they far too dangerous.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: not available
URL: <http://lists.puremagic.com/pipermail/digitalmars-d/attachments/20141119/e629be11/attachment.sig>


More information about the Digitalmars-d mailing list