4 ms·
You need both. The type system is not going to catch if you do Rectangle(width, height) where you should have done Rectangle(height, width).
by cjfd 3y ago
You need both. The type system is not going to catch if you do Rectangle(width, height) where you should have done Rectangle(height, width).
- haspok 3y agoMaybe _your_ type system doesn't do that. It is perfectly possible to introduce type aliases to differentiate between X and Y coordinates - though usually it is not worth the trouble. (Unless you are working on the firmware of a nuclear missile - in which case it probably is :))
- d-lisp 3y agoI personally have a lot of informations coming from my text editor (emacs) when writing code, and I only want to say that your example does the opposite of what you meant; because of the type system, typing Rectangle TAB would likely print Rectangle(width, height) automatically and inform you with "width, a 32 bit float; height, a 32 bit float". I fail to find a better example (complex functions of high arity with parameters from the same type ?).