Paladaxar
February 18th, 2008, 11:02 PM
WARNING: Theoretical question ahead...and may not be worth your time.
My friends and I are arguing right now about sub ranges. If we were to make a type "cents" that consists of the integers from 0-99, should we be able to multiply this type with itself or not?
I agree that 4*5 cents = 20 cents. Thats fine.
But 4 cents * 5 cents = 20 cents^2. Cents^2 is a meaningless unit.
So, I think that int*cent should be allowed, but cent*cent should not be allowed and should throw an error...because it makes no sense.
They are saying that any sub range needs to support all of the operations that its parent allows.
Any thoughts that might help us clear this up? I did a quick google search to see if i could come up with a professional opinion (a book or something) but didnt find anything.
My friends and I are arguing right now about sub ranges. If we were to make a type "cents" that consists of the integers from 0-99, should we be able to multiply this type with itself or not?
I agree that 4*5 cents = 20 cents. Thats fine.
But 4 cents * 5 cents = 20 cents^2. Cents^2 is a meaningless unit.
So, I think that int*cent should be allowed, but cent*cent should not be allowed and should throw an error...because it makes no sense.
They are saying that any sub range needs to support all of the operations that its parent allows.
Any thoughts that might help us clear this up? I did a quick google search to see if i could come up with a professional opinion (a book or something) but didnt find anything.