F#:实现具有与关键字begin相同的函数名的接口

use*_*855 5 f# identifier keyword

我正在尝试实现IVector接口,它是Microsoft.VisualC.StlClr命名空间的一部分.它有一个成员函数begin().如果我尝试实现该接口,那么它会抱怨"对象表达式中的意外关键字'begin'".

这是因为begin是一个关键字而我无法使用该名称实现成员函数?

B.

des*_*sco 5

你可以尝试将它包装成反引号.IVector接口太大而无法将其作为示例实现,因此示例将更小 - 下面的代码编译时没有任何错误.

// C#
public interface ITest
{
    void begin();
}

// F#
type Test() = 
    interface UStatic.ITest with
        member this.``begin``() = ()
Run Code Online (Sandbox Code Playgroud)