RE: Use of "unsigned" for non-enumeration values

Allen, Michael B (RSCH) [mailto:Michael_B_Allen@ml.com]  wrote:
> 	Actually in C at least I believe most users would 
> prefer 'int' because it's much easier to type and on most 
> systems INT_MAX is 2GB whereas UINT_MAX is 4GB which means 
> using unsigned is only
> (maybe) useful for marking stream positions and file sizes. 
> The use of unsigned long in methods like:
> 
> 	    void deleteData(in unsigned long offset, 
> 	                                       in unsigned long count)
> 	                                       raises(DOMException);
> 
> 	is obviously not necessary.  On systems where int is 16 
> bits or less a dom should probably not be manipulating 
> continuous strings of 32K considering the machine probably 
> wouldn't have much more main memory than that.

Can't go back and undo the past.  However, I'd strongly encourage C++ DOM's
to also expose signed variants of methods that take unsigned args.  The
signed methods would check for negatives and throw an exception (behaving
like the Java/JavaScript implementations) and then delegate to the unsigned
implementation.

Then the caller can then control whether the checking or unchecking
implementation is used by selecting to do the string math using either
signed or unsigned ints and avoid the transparent promotion to unsigned.

However, for new stuff there is no reason to continue doing the same old
thing.

Received on Thursday, 28 March 2002 19:22:15 UTC