Default method with tupled parameters for an F# class -


why f# class not compile(with vs2010):

type base =     abstract func : (int * int) -> int      default this.func (x : int, y : int) : int =         x + y 

the default implementation of func causes compilation error:

error   9   override takes different number of arguments corresponding abstract member 

if change member:

type base =     abstract func : (int * int) -> int      member this.func (x : int, y : int) : int =         x + y 

then compiles (though believe abstract func lacks implementation), , type of 2nd func matches 1st.

on related note, why doesn't compiler require 2nd definition of base have abstractclass attribute?

just rid of parentheses:

type base =     abstract func : int * int -> int      default this.func (x : int, y : int) : int =         x + y 

you can shorten bit:

default this.func(x, y) = x + y 

Comments