List Info

Thread: NATURAL_32 vrs. INTEGER_32




NATURAL_32 vrs. INTEGER_32
country flaguser name
United States
2008-03-19 13:21:34

I was working on a structure's feature `is_full' where it is true if
there are maximum number of items in it. I'm tempted to use NATURAL_32
as the number of items cannot be negative.

This also got me thinking about HASH_TABLE and HASH_TABLE.hash_code.
Theorectically, could these be NATURALs instead of INTEGERs?

What am I missing here? Is there a reason a new class should not use
NATURAL_xx in place of INTEGER for features such as `count',
`max_items', etc.?

jjj

__._,_.___
.

__,_._,___
RE: NATURAL_32 vrs. INTEGER_32
user name
2008-03-19 13:26:46

> This also got me thinking about HASH_TABLE and HASH_TABLE.hash_code.
> Theorectically, could these be NATURALs instead of INTEGERs?

Yes.

> What am I missing here? Is there a reason a new class should
> not use NATURAL_xx in place of INTEGER for features such as
> `count', `max_items', etc.?

Yes, if we were to rewrite everything from scratch, we would definitely use
NATURAL since they provide 2 major benefits:
- no need for assertions of the type `x >= 0'
- containers can now hold twice as much items as before (4G instead of 2G).

Manu

__._,_.___
.

__,_._,___
[1-2]

about | contact  Other archives ( Real Estate discussion Medical topics )