size_t index=-1;

Mathias Lang via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Wed Mar 16 15:37:40 PDT 2016


On Wednesday, 16 March 2016 at 21:49:05 UTC, Steven Schveighoffer 
wrote:
> No, please don't. Assigning a signed value to an unsigned (and 
> vice versa) is very useful, and there is no good reason to 
> break this.
>
> -Steve

I'm not talking about removing it completely. The implicit 
conversion should only happen when it's safe:

```
int s;
if (s >= 0) // VRP saves the day
{
   uint u = s;
}
```

```
uint u;

if (u > short.max)
   throw new Exception("Argument out of range");
// Or `assert`
short s = u;
```


More information about the Digitalmars-d-learn mailing list