两个简单的 F# 问题
我想理解 F# 的两个片段,但不知道该谷歌什么。第一:
let ``1+2`` () = ....
我猜这只是意味着“将表达式转换为标识符”?但如果我想引用这个功能,它叫什么?
其次,字符^
出现在类型中时意味着什么?我发现有几次提到它,但解释总是只是说“类型是这个”,而不是“它与没有 1^1 的类型不同......”。例如:
let inline blah x y = x+y;;
val inline blah :
^a -> ^b -> ^c
when ( ^a or ^b) : (static member ( + ) : ^a * ^b -> ^c)
非常感谢。
There are two snippets of F# I would like to understand, but don't know what to google. First:
let ``1+2`` () = ....
I am guessing this just means "turn the expression into an identifier"? But what is that feature called if I want to refer to it?
Second, what does the character ^
mean when it occurs in a type? I have found several mentions of it, but the explanation always just says "the type is this" rather than "it differs from a type without a 1^1 in that ...". For example:
let inline blah x y = x+y;;
val inline blah :
^a -> ^b -> ^c
when ( ^a or ^b) : (static member ( + ) : ^a * ^b -> ^c)
Many thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
反引号语法确实只是将任意字符“引用”到标识符中的一种方法,我不确定它是否有名称。它通常用于例如
或
克拉表示静态解析的类型参数:
http:// /msdn.microsoft.com/en-us/library/dd548046.aspx
用于临时重载/通用性。
The backquote syntax is indeed just a way to 'quote' arbitrary characters into identifiers, I am not sure if it has a name. It is typically used for e.g.
or
The carat indicates a statically resolved type parameter:
http://msdn.microsoft.com/en-us/library/dd548046.aspx
used for ad-hoc overloading/genericity.