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

Marco Leise via Digitalmars-d digitalmars-d at puremagic.com
Fri Nov 21 12:08:13 PST 2014


Am Thu, 20 Nov 2014 07:42:20 +0000
schrieb "FrankLike" <1150015857 at qq.com>:

> > That I partially, fractionally even, agree with. We agonized 
> > for a long time about what to do to improve on the state of the 
> > art back in 2007 - literally months I recall. Part of the 
> > conclusion was that reverting to int for object lengths would 
> > be a net negative.
> >
> > Andrei
> 
> All of these discussions, let me known how to do about 'length',D 
> better than c,it's a system language.
> 
> For WindowsAPI: cast(something)length ,and other modify it to 
> size_t.
> 
> Thank you all.

The correct thing is to use for WindowsAPI: length.to!int
It checks if the length actually fits into an int.

-- 
Marco



More information about the Digitalmars-d mailing list