0

I love purely functional languages like haskell and erlang, because of their strong control over mutation, but there are practical aspects of them I really don't like. Specifically, I think it's ridiculous that neither has support for named optional arguments to functions like python has. Named optional arguments are ridiculously ridiculously useful. I honestly think they are the number one reason people like python so much. They are obviously compatible with the idea of strong mutation control, so is there a language out there with strong mutation control and named optional arguments?

As a preemptive response to the pedantic weenies who will say that haskell actually does have support for named optional arguments, I have seen what constitutes such a thing in haskell (https://github.com/Gabriel439/Haskell-Optional-Args-Library/blob/master/src/Data/Optional.hs, https://stackoverflow.com/questions/7781096/is-there-a-better-way-to-have-optional-arguments-in-haskell or http://neilmitchell.blogspot.ca/2008/04/optional-parameters-in-haskell.html for example) and it's massively fugly compared to python. Ditto, erlang.

I understand that haskell's strict one input, one output approach to functions is probably incompatible with the idea of optional arguments, as implemented in python, but I think this one in, one out approach is much more of a nerdy mathy doing-things-because-we-can kind of thing than it is an actually useful language feature. Go ahead and ask me why somewhere else, but the point is whatever replacement I seek does not have to (and probably couldn't) work under the same one input, one output principle and I am completely OK with that.

1 Answer 1

1

A quick web search revealed this page at Rosetta Code with code samples in a number of languages: https://rosettacode.org/wiki/Named_parameters

I would rather have left this as a comment, but lack of reputation dictates that it becomes an answer instead. I might as well elaborate:

I have first-hand experience of only a few of these, so I can't say for sure which ones fit in to your other requirements. Common Lisp and Racket are two from this list that I have tried myself and that I consider to be somewhat friendly to an immutable programming style. Clojure is in there too, but with no "native" support for named parameters (although there is an example of implementing it in Scheme on the very same page, so you could probably implement it in Clojure as well, has it has closures and macros).

There is also F#, which I have not tried but which has both named and optional parameters according to the documentation. My understanding is that this is a language that has some philosophical similarities to Haskell.


I guess my answer is F#, or one of many Lisp flavors.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.