Lars Wirzenius is a user on You can follow them or interact with them if you have an account anywhere in the fediverse. If you don't, you can sign up here.
Lars Wirzenius @liw

More things I need to re-learn: the optimal number of function argumetns is 0, but 1 is OK. More than 3 is a recipe for bugs.

· Web · 0 · 1

@liw That seems especially true for dynamic languages or static languages where a function has multiple arguments with the same type.

@cstanhope I agree partially, but it's also true for C and languages like that. A C function that gets a long list of arguments can often easily be called with arguments in the wrong order. It may be a little easier to catch in C, but only when the arguments are of incompatible types.

The number of types I've called strcpy(src, tgt) is scary, and it's not always possible to have src be const.

Or was it strcpy(tgt, src)?

This is not a language comparison fight.

@liw No fight from me! :) I was just thinking it through about how broadly your observation applies and how it even applies with static languages. Every time I have a functions whose argument list seems to be growing, I start to think of ways to reduce it or make it harder to to call it wrong. Although, I admit I spend more effort on public facing functions than private ones.

@liw And static types don't help when things are silently cast too... Oh my gosh, I'm having flashbacks...