F#:为什么我不能在松散函数中使用可选参数? [英] F#: Why can't I use optional parameters in loose functions?

查看:67
本文介绍了F#:为什么我不能在松散函数中使用可选参数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为什么我不能在用"let"定义的松散函数中使用可选参数?

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

为什么仅在成员函数中允许使用它们?

Why are they only allowed in member functions?

推荐答案

我怀疑提供它们只是为了与.NET函数兼容.它们不是您在功能语言中遇到的东西.可选参数的问题是您不能使用它.如果函数f的第二个参数是可选的,什么是

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

让g = f x
?

let g = f x
?

是接受一个参数的函数,还是通过对x求f加上默认的第二个参数获得的值?

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

这篇关于F#:为什么我不能在松散函数中使用可选参数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆