Hacker News new | ask | show | jobs
by fixermark 3842 days ago
shrug It'd be one more special case for the compiler to handle (and one more feature for my brain to hold onto when reasoning through code... "This is being called with two arguments, is that a typo or does this function take default arguments? Guess I'll have to go look up the function's declaration...").

I can see the alternate viewpoint but given that we can use structs and default fields to get the same effect I'm happy with the current solution.

1 comments

> I can see the alternate viewpoint but given that we can use structs and default fields to get the same effect I'm happy with the current solution.

And that's completely fair, I routinely use languages both with and without optional parameters[0] and that's fine I'm not saying languages must[1] have optional parameters, or even that they should[1]. My comment only tries to humorously denote that the claim I quoted is pure lunacy.

> we can use structs and default fields

Don't forget the builder pattern which works pretty well to replace optional parameters (and keyword/named parameters), though it's less convenient on the implementer's side.

[0] whether in the "native" sense à la Python or C#, in the "overloaded method" sense à la C++ or Java or in the "well your question doesn't even make sense" à la Smalltalk

[1] in an RFC 2119 sense