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

ketmar via Digitalmars-d digitalmars-d at puremagic.com
Fri Nov 21 18:20:31 PST 2014


On Fri, 21 Nov 2014 12:35:31 -0800
Walter Bright via Digitalmars-d <digitalmars-d at puremagic.com> wrote:

> 'auto' doesn't mean "break my code if I refactor out expressions into temporaries".
this can be easily avoided: just don't use `auto` for refactoring. i'm
still thinking about `auto` as "any type that is able to hold the
result". `uint` is obviously not able to hold the result of uint
subtraction (as it can be negative, and uint can't). so when compiler
automatically chooses the type which can't hold the resulting value, i
see this as a design flaw and safety breaking feature.

one of D flaws -- as i can see it -- is trying to be both a reasonably
high-level and "close to metal". it's ok for "metal" language to use
uint to hold that result and wrap. but it's not ok for high-level
language, high-level language should free me of thinking about
"wrapping", "overflow" and so on.

i'm not telling that D is bad, i'm simply trying to tell that such
confusions will raise again and again. "too far from metal" vs "too
close to metal".

i may just not get the whole concept, so i don't know what to expect in
such cases. sometimes D amuses me with it's shamelessly breakage of
principle of least astonishment. but yet again it very well can be flaw
in my brains and not in D.
-------------- 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/20141122/655035df/attachment.sig>


More information about the Digitalmars-d mailing list