F#: Why can't I use optional parameters in loose functions?

≡放荡痞女 提交于 2019-11-29 13:26:45

I suspect they are provided only for compatibility with .NET functions. They aren't something you encounter in functional languages. The problem with an optional parameter is you can't curry it. If a function f's second parameter is optional, what is

let g = f x
?

Is it a function taking one argument, or a value obtained by evaluating f on x plus the default second parameter?

It is allowed in OCaml. Therefore it should be possible to implement it in F#.

http://caml.inria.fr/pub/docs/manual-ocaml/lablexamples.html#sec43

I guess it has been omitted for simplicity in F#.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!