Basic question about size_t and ulong

Era Scarecrow rtcvb32 at yahoo.com
Wed Mar 23 00:51:42 UTC 2022


On Tuesday, 22 March 2022 at 21:23:43 UTC, H. S. Teoh wrote:
> On Tue, Mar 22, 2022 at 09:11 PM, Era Scarecrow wrote:
>> [...]
>> I'd almost wish D had a more lenient mode and would do 
>> automatic down-casting, then complain if it *would* have 
>> failed to downcast data at runtime.
>> [...]
>
> We already have this:
>
> 	import std.conv : to;
> 	int x;
> 	long y;
> 	y = x.to!long;	// equivalent to straight assignment / cast
> 	x = y.to!int;	// throws if out of range for int

  At which point I might as well just do cast(int) on everything 
regardless **BECAUSE** the point of it is **NOT** having to add a 
bunch of conversions or extra bits to it.

  This particular usage can be useful, just not in the *automatic* 
sense i was meaning.


More information about the Digitalmars-d-learn mailing list