Author Topic: Function pointers  (Read 1509 times)

0 Members and 1 Guest are viewing this topic.

José Roca

  • Guest
Function pointers
« on: October 04, 2018, 03:18:08 PM »
This "gibberish" needs some explanation, specially the "#" part.

Code: [Select]

function f(sys a) as sys
  print "ok" a
end function

declare function ptr f1(sys a) as sys
! * f2(sys a)
int (* f3)(int a)

@f1=@f#sys
@f2=@f#sys
@f3=@f#sys

'#recordof f3

f1 1
f2 2
f3 3

Charles Pegge

  • Guest
Re: Function pointers
« Reply #1 on: October 04, 2018, 03:35:33 PM »
Very briefly:

This gibberish :)  demonstrates alternative ways of declaring a function pointer. f#sys is the name of the function as seen by the compiler. The parameter signature is appended to the name. For instance myfun#double#string. The signature is used to distinguish function polymorphs.

An external or callback function, like WndProc does not require a signature, however.

José Roca

  • Guest
Re: Function pointers
« Reply #2 on: October 04, 2018, 04:42:48 PM »
You're having fun with these alternate syntaxes, don't you? :)

I'm gonna go crazy.

JRS

  • Guest
Re: Function pointers
« Reply #3 on: October 04, 2018, 06:29:22 PM »
You're having fun with these alternate syntaxes, don't you? :)

I'm gonna go crazy.

BASIC without chains or preconceived notions. I'm happy I'm along for the ride.

Charles Pegge

  • Guest
Re: Function pointers
« Reply #4 on: October 05, 2018, 12:16:29 AM »
I'll settle for the shortest syntax :)

José Roca

  • Guest
Re: Function pointers
« Reply #5 on: October 05, 2018, 06:28:10 AM »
Me too, but only if it doesn't make the code look encrypted.