'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:57:27 PST 2014


On Wed, 19 Nov 2014 13:47:50 +0000
Don via Digitalmars-d <digitalmars-d at puremagic.com> wrote:

> > yes. besides, there is no such thing as "negative length", so 
> > it's
> > somewhat... weird to use signed integer for length.
> 
> A length can certainly be negative. Just as a bank balance can be 
> negative. It's just a number.
what is the relation between bank balance and length? please, show me
the array with -1 element, so i can see negative length myself.

seems to me that you are using "length" as "quantity", but that isn't
right.

> If I have two pencils of length 10 cm and 15 cm, then the first 
> one is -5 cm longer than the other.
and again "length" is not a relation. show me pencil of length -10 cm.
when you substractin lengthes, you got completely different type as a
result, not "length" anymore. ah, that untyped real-life math! ;-)

> Of course any physical pencil is always of positive length, but 
> that doesn't mean that typeof(pencil.length) can never be 
> negative.
it can't be negative. if it can be negative, it is wrongly named,
it's not "length".
-------------- 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/7c631238/attachment.sig>


More information about the Digitalmars-d mailing list