Page 1 of 1

[Implemented] Function pointers

Posted: Thu Oct 06, 2005 12:25 pm
by remi_meier
I would like to see something like

Code: Select all

Declare.l test(a.l)
test() = IsFunction(0, "spk")
test(4)

and

CDeclare.l test(a.l)
test() = IsFunction(0, "spk")
test(4)

or

*test = IsFunction(0, "spk")
*test(4)
in PB.

CallFunctionFast has some disadvantages:
- needs some more time
- long name
- not as readable as my requests
- needs a wrapper function again for floats and better readability

Posted: Thu Oct 06, 2005 5:10 pm
by Fred
True, this is will added in v4 (and CallFunction/CallFunctionFast will be probably removed).

Posted: Thu Oct 06, 2005 5:31 pm
by Polo
REALLY good news !!

Posted: Thu Oct 06, 2005 6:09 pm
by MrMat
Fred wrote:True, this is will added in v4 (and CallFunction/CallFunctionFast will be probably removed).
This is a contrived example, but i just want to check that it will still be possible (if CallFunctionFast gets removed):

Code: Select all

Procedure A()
Debug("A")
EndProcedure

Procedure B(p.l)
Debug("B" + Str(p))
EndProcedure

Dim addr(10)

For m = 0 To 10
If m < 5
addr(m) = @A()
Else
addr(m) = @B()
EndIf
Next

For m = 0 To 10
If m < 5
CallFunctionFast(addr(m))
Else
CallFunctionFast(addr(m), m)
EndIf
Next
So please reassure me :D

Posted: Thu Oct 06, 2005 6:54 pm
by Fred
replace addr(m) with 'test' and it will work. It's just a pointer where you can put any value in..

Posted: Thu Oct 06, 2005 7:08 pm
by remi_meier
Thanx a lot Fred!

Posted: Thu Oct 06, 2005 7:12 pm
by MrMat
Thanks Fred and thanks for your IRC explanation. All seems good! :D