我需要分配給一個byref參數,但在Windows 8x64盒子上使用F#4.0和.NET 4.5.2,我總是收到我不能更改簽名的投訴,因爲我實現一個COM接口。最小破例如:F#byref param不可變
module Utils =
let bugFix1([<System.Runtime.InteropServices.Out>] ID : System.String byref) = ID <- "Hi!"
let bugFix1([<System.Runtime.InteropServices.Out>] ID : int byref) = ID <- 0
let bugFix1([<System.Runtime.InteropServices.Out>] ID : System.Guid byref) = ID <- System.Guid.NewGuid()
通過this value
,它肯定意味着ID
,因爲它並不重要我分配到ID
。還要注意,這個類型是否可以啓動,或者是堆棧還是堆棧分配都沒有關係。
有什麼辦法可以申報ID
爲mutable
?
也許是重複或至少類似http://stackoverflow.com/questions/946338/f-how-do-i-declare-and-use-byref-semantics-on-parameters –
什麼F#版本你使用? –
@FyodorSoikin好點 - 4.0。我已經編輯了這個問題。 –