std.digest toHexString

Kagamin via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Mon Mar 20 08:38:26 PDT 2017


On Thursday, 16 March 2017 at 17:50:45 UTC, Adam D. Ruppe wrote:
> string s = func()[]; // I'd allow it, at least the user wrote 
> `[]` meaning they realized it was stack data and presumably 
> knows what that means about the slice's lifetime

This explicit slice won't work, because a slice of a fixed size 
array results in a fixed size array.

There's no reason to allow this buggy code though. Also 
programmer didn't necessarily mean it. It could be a typographic 
error or a result of refactoring. Even if programmer wanted to 
write invalid code, what for? Yet this particular code doesn't 
need to be allowed to allow writing invalid code: one can still 
cast a number to pointer and do whatever he wants.


More information about the Digitalmars-d-learn mailing list