[Implemented] Function pointers

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
remi_meier
Enthusiast
Enthusiast
Posts: 468
Joined: Sat Dec 20, 2003 6:19 pm
Location: Switzerland

[Implemented] Function pointers

Post 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
Athlon64 3700+, 1024MB Ram, Radeon X1600
Fred
Administrator
Administrator
Posts: 18162
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Post by Fred »

True, this is will added in v4 (and CallFunction/CallFunctionFast will be probably removed).
Polo
Addict
Addict
Posts: 2422
Joined: Tue May 06, 2003 5:07 pm
Location: UK

Post by Polo »

REALLY good news !!
MrMat
Enthusiast
Enthusiast
Posts: 762
Joined: Sun Sep 05, 2004 6:27 am
Location: England

Post 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
Mat
Fred
Administrator
Administrator
Posts: 18162
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Post by Fred »

replace addr(m) with 'test' and it will work. It's just a pointer where you can put any value in..
remi_meier
Enthusiast
Enthusiast
Posts: 468
Joined: Sat Dec 20, 2003 6:19 pm
Location: Switzerland

Post by remi_meier »

Thanx a lot Fred!
Athlon64 3700+, 1024MB Ram, Radeon X1600
MrMat
Enthusiast
Enthusiast
Posts: 762
Joined: Sun Sep 05, 2004 6:27 am
Location: England

Post by MrMat »

Thanks Fred and thanks for your IRC explanation. All seems good! :D
Mat
Post Reply