On Thursday, 18 January 2024 at 02:55:37 UTC, zjh wrote:
Can you change the type of 'length' from 'ulong' to 'int', so I haven't to convert it every time!

The explicit conversion `.length.to!int` has an extra benefit of doing a runtime check to ensure that the length value actually fits in an `int` variable. Just in case if somebody tries to use your code to process a 3GB array of bytes.

It's more correct to rewrite the code to expect `size_t`. But one needs to be very careful about implementing it correctly, because silent casts between signed and unsigned data types may ruin your day. It's a major source of bugs, similar to the one discussed in https://forum.dlang.org/thread/vyvbrtmyelududcvu...@forum.dlang.org

Reply via email to