I'm afraid this is a limitation of F# quotations (there are a couple of others), that you can't do much about. It seems that it's just not possible to use 'byref' types in the quoted code. I'd probably write my own function that encapsulates Interlocked.Add without using 'byref' types and then call this function from the quoted code (your quotation analyzer can easily deal with one additional 'special' function). Something like this:

1
2
3
4
5
6
7
8
9
 
open System
open System.Threading

let interlockedAdd (a:int[]) i n = 
  Interlocked.Add(&(a.[ i ]), n) |> ignore
  
[<ReflectedDefinition>]
let myFunc (i:int) (a:int[]) = interlockedAdd a i 7
By on 2/3/2010 3:25 PM ()

Thanks Tomas. It does the trick pretty nicely.

By on 2/3/2010 4:28 PM ()
IntelliFactory Offices Copyright (c) 2011-2012 IntelliFactory. All rights reserved.
Home | Products | Consulting | Trainings | Blogs | Jobs | Contact Us | Terms of Use | Privacy Policy | Cookie Policy
Built with WebSharper