3 ms·
> too few arguments” always an illogical answer If you write math/algo code, yes. Most other types of code benefit a lot from: - variable numbers of arguments
by nnq 10y ago
> too few arguments” always an illogical answer
If you write math/algo code, yes. Most other types of code benefit a lot from:
- variable numbers of arguments
- default argument values (to practically make use of the one above)
- named/keyword arguments (usually combined with default arg values in same use, which will make obvious the need for specifying arguments in variable orders)
And of course that if you have these, you really don't want to also have auto-currying because it would make implementation hard and code reading or debugging a nightmare! (especially in a dynamic language)
...which may seem like an abomination for both the "clean code / uncle Bob's disciples" side which prefers methods of less that 3 arguments (but apparently they don't mind having a zillion of them spread in a zillion little classes), and for the "strict and auto-curried functional programming" side.
But for real world code written under real deadlines, usually without the time to RTFM of every lib and api you use, makes life 100x easier for regular programmers which aren't always fast enough to get the right abstraction in the allocated time or have good enough memory to figure out the right order and number of arguments a function takes in all cases!
(imho both Clojure and CL seem to have gotten these things right...)
- tempodox 10y agoI hear you and I don't disagree. As far as discoverable / self-explanatory API goes, named arguments are a great help. OCaml gives you those, and optional named args with default values. Which, together with strict & strong typing (plus other FP perks), makes the best of both worlds for me.
- nnq 10y ago> OCaml gives you those I know. And I learned it up to a point... But for me it unfortunately falls into that uncanny valley between truly elegant languages (Haskell, Scheme) and truly practical languages (Python, Ruby, Go). Neither elegant enough nor practical enough for my use. Probably better for other people's uses.