Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Function Pointers?
#1
I tried searching but didn't see anything...

It's an odd request, but I'm a big fan of function pointers/dispatch tables. I always want one more level of indirection Smile

Using a big Select Case instead of an array of a UDT type with a pointer will get the job done and is no hardship, but it never hurts to ask. so this is more of a want than a need and it's certainly not a typical Basic sounding thing.

As an aside I've been "futzing" around with QB64PE for the past couple of weeks and the experience on the Mac has been great. I've tried a few times in the past but kept drifting away. Solid work you all have been doing.
Reply
#2
I'm onboard with this.   BUT I'M NOT A COMPILER DEV ! 

   It is kind of outside of what BASIC normally is and I woudn't hold my breath.   
I do know you can work with function pointers in a C interface library to the 
main program but that isn't the same !

   Depending on use case you want I've used Conditional compilation to do
a kind of sort of call back type function, but that really isn't the same thing
(But might be a road to explore for certain applications !)
Reply
#3
There's been some consideration of the idea (see https://github.com/QB64-Phoenix-Edition/.../issues/48) but it probably won't be happening in the near future. Lots of prickly edge cases.
Reply
#4
(02-19-2026, 08:50 PM)luke Wrote: There's been some consideration of the idea (see https://github.com/QB64-Phoenix-Edition/.../issues/48) but it probably won't be happening in the near future. Lots of prickly edge cases.
Yeah I can see that. Thanks. I need to make sure my searches pick up the repo too.
Reply
#5
if you think you need function pointers.  program in c++.  otherwise wait until this dialect of basic.  develops more oop-like features.

if this is too much to take.  switch to freebasic.  which supports oop more or less like microsoft visual basic.

however if you really need the "advanced" graphics and sound.  that qb64 phoenix provides.  you need to look at what could require function pointers.  try to do it in c++ or other language.  because someone who thinks he/she needs function pointers.  will also ask for variable number of subprogram parameters.  multiple return values from function.  function and operator overloading.  so on and so forth.  as i've said, oop-like features.

it could be handled creatively.  by writing one subprogram.  which has select case... end select to go through possible "mini-methods."

or handle that selection in the "main program."  with many custom subprograms to choose from.  the difference is that there's no need.  not even in c/c++ to use pointers for it.  just integers or maybe key string values.  to select what should be called. (shrugs)
hopeless addict of dying in the first few levels of two particular console viewport "roguelike" games
Reply
#6
I only want function pointers because I'm lazy and do old style table driven code. A definite want but by no means a need. As I said, a big select is no hardship, just checking.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  function "_ARCSEC()" is wrong? BSpinoza 16 3,420 10-31-2023, 04:23 PM
Last Post: SMcNeill
  TYPE and CONST within SUB/FUNCTION TerryRitchie 9 1,942 07-11-2023, 01:22 AM
Last Post: bplus
  Query to function _InputBox$ Petr 10 2,031 03-31-2023, 09:53 PM
Last Post: mnrvovrfc
  instr function in reverse ??? doppler 3 750 02-10-2023, 02:33 PM
Last Post: doppler
  Variable as a reference or value to a function Kernelpanic 22 4,251 08-08-2022, 07:41 PM
Last Post: bplus

Forum Jump:


Users browsing this thread: