As you say, you need to use &arg at any byref call site.

I also see that if the 'let' is bound inside a class it does not work (I'm unsure why offhand), but moving it outside the class to module scope works:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
 

type IFoo =
    abstract Foo : x:int * y:int byref -> int

// does work to define 'let' at module scope
let impl(x:int, y:int byref) : int =
    y <- x
    x + 1

type MyFoo() =
// does not work to define this inside a class and try to call it
//    let impl(x:int, y:int byref) : int =
//        y <- x
//        x + 1

    let impl2(x:int, y:int byref) : int =
        impl(x, &y)
        
    member this.Bar(x:int,y:int byref) = 
        let z = y
        printfn "%d" z
        impl(x,&y)

    interface IFoo with
        member this.Foo(x:int,y:int byref) = 
            impl(x,&y)
By on 3/29/2010 5:56 PM ()

ok, this sounds like a bug, i see no resaon why this should not be possible..

I can confilm, that it works when i move the function out of the class into a common module. but this is no solution for me, since i have to use class members in that function.

maybe it works as a member function instead of a let binding of the class.. i try that.

By on 3/29/2010 6:15 PM ()

yea, that was the solution, it works as a member function of the class, but only with a tuple argument..

1
2
3
4
5
6
7
8
9
10
member this.getTex (forPin, onDevice, texturePointer:int byref) =
        texturePointer <- 0
        if forPin = myTextureOut then
            let t = FDeviceTextures.[onDevice]
            if not (t = null) then
                texturePointer <- t.ComPointer.ToInt32()


interface IPluginDXTexture with
        member this.GetTexture(forPin, onDevice, texturePointer) = this.getTex (forPin, onDevice, &texturePointer)

strage, i still believe its a bug..

thanks for the fast answer!

By on 3/29/2010 6:33 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