No argument names in abstract declaration?

后端 未结 2 1134
独厮守ぢ
独厮守ぢ 2021-02-05 03:04

This is the typical declaration of an abstract member in F#:

abstract member createEmployee : string -> string -> Employee

You define the

相关标签:
2条回答
  • 2021-02-05 03:29

    The syntax for this is super fiddly IMO. I wanted to do this with the parameters as a tuple (like a C# method) and only through trial and error did I find this to work:

        abstract member PutChar : x:int * y:int * c:char * flag:Background -> unit
    

    And this uglier variant also works:

        abstract member PutChar : x : int * y : int * c : char * flag : Background -> unit
    

    Below are things that all felt reasonable but failed with the same error - Unexpected symbol ':' in member definition.:

        // ALL BAD vvv
        abstract member PutChar : (x:int * y:int * c:char * flag:Background) -> unit
        abstract member PutChar : (x:int, y:int, c:char, flag:Background) -> unit
        abstract member PutChar : (x:int) * (y:int) * (c:char) * (flag:Background) -> unit
        // ALL BAD ^^^
    
    0 讨论(0)
  • 2021-02-05 03:40

    What about:

    abstract member createEmployee : firstName:string -> lastName:string -> Employee
    

    ?

    0 讨论(0)
提交回复
热议问题