4 ms·
> When I look at a method declaration, I want to know that it only works with integers, the same way I look at a field in the database I want to be sure to expe
by anamax 16y ago
> When I look at a method declaration, I want to know that it only works with integers, the same way I look at a field in the database I want to be sure to expect only integers, and nothing else.
That's fine, but it doesn't help me with the errors that I make.
I don't make representation errors. I make kind errors. The difference is that the number of apples and the number of bananas are both non-negative integers, but a check for non-negative integers doesn't keep me from adding apples to my bananas inventory. Remember that I do want to add both apples and bananas to my fruit inventory.
Yes, I care about representation, but things shouldn't go south if I happen to have half an apple.
- aristidb 16y agoIn some statically typed languages, it is possible to have an "Apples" and a "Bananas" type. And it's good to hear that you don't make "representation errors", because I do make these errors - which then blow up precisely after 3 hours of running the Python program.
- pbz 16y agoNo quite sure what you mean, if you write something like this: void DoSomething(Fuit fruit, uint quantity) { .. } Inside that method you will be guaranteed to receive only apples or bananas and a non-negative integer for quantity.