• Print

Author Topic: discussion: pointers to functions, and are they in the spirit of BASIC?  (Read 609 times)

Clippy

  • Hero Member
  • *****
  • Posts: 16440
  • I LOVE π = 4 * ATN(1)    Use the QB64 WIKI >>>
    • Pete's Qbasic Site
    • Email
Re: discussion: pointers to functions, and are they in the spirit of BASIC?
« Reply #15 on: January 23, 2013, 10:08:20 AM »
Just because people use Basic doesn't mean they are totally ignorant or want to remain that way.

What I need to know is what USE the keywords are. If it is just to add another way to get information I can already get then show us why we need it. Is it _ALIAS or _AILAS?
QB64 WIKI: Main Page
Download Q-Basics Code Demo: Q-Basics.zip
Download QB64 BAT, IconAdder and VBS shortcuts: QB64BAT.zip
Download QB64 DLL files in a ZIP: Program64.zip

DSMan195276

  • Hero Member
  • *****
  • Posts: 1985
  • Yes
    • Email
Re: discussion: pointers to functions, and are they in the spirit of BASIC?
« Reply #16 on: January 23, 2013, 01:12:27 PM »
Quote
What I need to know is what USE the keywords are. If it is just to add another way to get information I can already get then show us why we need it. Is it _ALIAS or _AILAS?

Sorry, it was probably a typo on my part, _ALIAS. Same as ALIAS, as it relates to that. It would add functionality that's currently impossible in QB64 without some external C/C++ via DECLARE LIBRARY.

Basically, the idea is: Let's say you were writing a library, and at a specific you want to call a user-defined SUB/FUNCTION. You could hard-code the function name (And thus force the user to 1. have to use that name 2. only be able to use one function for that action). Or, you could tell them to send you a function pointer. By sending a function pointer, you can specify to the library what function you want it to run when it reaches that point. In effect, it's like telling the library what the name of the function you want to run is. It's also changeable during runtime so if you wanted to change that function to do something else, you could, instead of having some type of flag variable or something like that, just switch the function you're using.

This also allows us to use DECLARE LIBRARY with libraries that use and take function pointers, as well as allows a much easier time creating libraries and other parts of code.

Basically, it allows you to get a handle to a function while your code is running, and by doing that you can switch around what functions are called when and by what just by changing the function handle. Take for instance the _GL sub. Right now, it's use requires using various types of flags as well as dumping all of your GL code into that one function. If instead my suggested command were to be used, then you would just make an _ALIAS to the function you want to use as your _GL function, and then call a function that set's the current _GL SUB to that function. By doing this, you could also use this same type of thing to either disable the _GL function or switch functions so that a different SUB is used as the _GL function at different points in your program.

Matt
"Cast your cares on the Lord and he will sustain you; he will never let the righteous be shaken" -- Psalm 55:22
QB64 Linux Installer

bhamilton

  • Newbie
  • *
  • Posts: 7
Re: discussion: pointers to functions, and are they in the spirit of BASIC?
« Reply #17 on: January 31, 2013, 11:25:31 AM »
As someone who has been using "BASIC" since somtime around 1965 when it was being invented at Dartmouth (where I was an undergraduate), I can tell you that GWBASIC, QuickBasic, and QB64 all bear very little resemblence to "BASIC" as envisioned at the time.  It wasn't even trying to be a Programmers language.  The concept was a "user/designer" tool, to be used by non "programmers"  (I was an English major).

That was then, and this is now.  I don't see adding features as a drawback to the evolution of the language.

One can write "pure" QB4 code or convert it simply whithout using any of the QB64 _Keywords, but I for one am certainly taking advantage of those "non-basic" instructions.  For that matter, I am taking advantage of some very useful Windows API's through declaring fuctions within Libraries.  (Neither of these concepts existed in "pure" BASIC, nor for that matter did callable SUBS nor FUNCTIONS, nor Compilers).





TerryRitchie

  • Hero Member
  • *****
  • Posts: 2264
  • FORMAT C:\ /Q /U /AUTOTEST (How to repair Win8)
    • Email
Re: discussion: pointers to functions, and are they in the spirit of BASIC?
« Reply #18 on: January 31, 2013, 08:12:27 PM »
I couldn't have stated it better bhamilton. If QB64 were simply a 32/64bit compatible version of QuickBasic I would be happy, because I could keep programming in a language that allows me to write useful programs quickly. But, because of the additional QB64 only commands I am well beyond happy. See -->  ;D

I love the way Galleon has added these new commands while keeping the "BASIC" feel to them.  My only wish is that trend continues with any new commands added in the future.

I would love to see some of the more powerful PDS7 and VBDOS commands added as QB64 only commands as well.  So what if they were not QuickBasic native.

fatman2021

  • Hero Member
  • *****
  • Posts: 978
  • Lord Jesus Christ, Son of God, have mercy on us.
    • Email
Re: discussion: pointers to functions, and are they in the spirit of BASIC?
« Reply #19 on: March 01, 2013, 01:49:37 PM »
I am all for using function pointers. Mostly for calling machine code.
Woe to those who call evil good, and good evil;
Who put darkness for light, and light for darkness;
Who put bitter for sweet, and sweet for bitter!

Isaiah 5:20

DSMan195276

  • Hero Member
  • *****
  • Posts: 1985
  • Yes
    • Email
Re: discussion: pointers to functions, and are they in the spirit of BASIC?
« Reply #20 on: April 09, 2013, 12:01:29 PM »
Have any considerations been made for function pointers yet?

Matt
"Cast your cares on the Lord and he will sustain you; he will never let the righteous be shaken" -- Psalm 55:22
QB64 Linux Installer

  • Print