Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Why can't I use optional parameters in loose functions defined with "let"?

Why are they only allowed in member functions?

like image 775
Jonathan Allen Avatar asked Jun 03 '09 17:06

Jonathan Allen


1 Answers

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?

like image 119
Drew Hoskins Avatar answered Sep 24 '22 22:09

Drew Hoskins