On Monday, 13 October 2014 at 08:29:42 UTC, 岩倉 澪 wrote:
From what I've found, there was some work on this in the past (http://forum.dlang.org/thread/[email protected]?page=6#post-thclpgdlfxxhhfklwsoj:40forum.dlang.org), but a pull request was never made/I don't seem to find discussion about adding it as a feature anywhere.

I think optional named parameters would be a nice addition, either to the core language, or something like the monadic solution from that old thread in phobos.

Are there good reasons not to add something like this to the language, or is it simply a matter of doing the work? Has it been discussed much?

My limited Scala experience from several years ago suggests this is not something worth doing. The names of parameters are part of the API. Suppose you have a method like

def foo(x: int = 1000, y: double = 0.0): double {}

If you later change the names to something more informative

def foo(reps: int = 1000, variance: double = 0.0): double {}

you've potentially broken existing code. Maybe there are better approaches than that of Scala, but doing anything like that to D would be a huge mistake for little gain. (I write a lot of R code, for which named parameters are the norm, so I understand the convenience.)

Reply via email to