Я переписал некоторые свои определения функций f # в статические члены и застрял в ошибке параметра ref / byref:
static member bar (a : byref<int>) = Foo.bar &a
Error FS0001 This expression was expected to have type
'int ref'
but here has type
'byref<'a>'
Есть ли различия в параметрах byref между определениями let и static?
UPD:
Это работающий пример того, что я изменил определение статического члена:
> let rec foo (a :byref<int>) =
a <- a-1
if a > 0 then
System.Console.Write(a.ToString()); foo &a
else a
;;
val foo : a:byref<int> -> int
> let mutable a = 3;;
val mutable a : int = 3
> foo &a;;
21val it : int = 0
Теперь это выглядит так, и это не работает.Почему?:
> type Foo() =
static member bar (a : byref<int>) =
a <- a-1
if a > 0 then
System.Console.Write(a.ToString()); foo &a
else a;;
type Foo =
class
new : unit -> Foo
static member bar : a:byref<int> -> int
end
> let mutable b = 3;;
val mutable b : int = 3
> Foo.bar &b;;
Foo.bar &b;;
--------^^
stdin(71,9): error FS0001: This expression was expected to have type
'int ref'
but here has type
'byref<'a>'