std.algorithm.remove and principle of least astonishment

spir denis.spir at gmail.com
Wed Nov 24 07:27:33 PST 2010


On Wed, 24 Nov 2010 13:39:19 +0100
Don <nospam at nospam.com> wrote:

> I think we're seeing the exact same issue that causes to people to 
> mistakenly use 'uint' when they mean 'positive integer'.
> It LOOKS as though a char is a subset of dchar (ie, a dchar in the range 
> 0..0x7F).

Cannot be, in the sense of uint beeing a subset ulong. That's why "char", if not perfect, is a good name, providing the programmer with a hint about actual semantics. What i don't understand is why people who need unsigned bytes do not use ubyte? But instead bug into char. Is this only because of C baggage?

> It LOOKS as though a uint is a subset of int (ie, an int in the range 
> 0..int.max).

This indeed is a big issue. I would prefere uint (= Natural) to be implemented as a subset of int:
	uint	       0 --> +7fffffff 
	int	-f000000 --> +7fffffff

Denis
-- -- -- -- -- -- --
vit esse estrany ☣

spir.wikidot.com



More information about the Digitalmars-d mailing list