Meta Commands
#14
The whole changelog entry was just:

Quote:Fixes issue with recursive functions without parameters.

Not much to tell you there, about how it broke folks code.  Tongue

Prior to 1.5 (or 2.0, as the "fix" was listed as a 2.0 achievement), people would write a lot of code such as:

Code: (Select All)
FUNCTION foo
IF junk < 10 THEN foo = foo OR 1
IF junk >9 AND foo < 100 then foo = foo OR 2
IF junk > 99 and foo < 1000 THEN foo = foo OR 4

After the fix, all this old code was broken and no longer worked.  QB64 had always previously considered a variable inside a function to be the name of the function, and an assignment value.   After the fix, only the name on the left side of the equal sign was a name -- the name on the right side of the equal sign was now a recursive call back to the same function.

Lots of old code broke -- after all, people had only had 15 years or so to adapt to coding with the concept that "inside a function, the name references the function itself.  If one wants a recursive call, then one should pass a parameter for use with recursion."

For example -- an old recursive call to a function would look like:

Code: (Select All)
FUNCTION foo (dummy)

    IF junk < 10 THEN foo = foo(0) OR 1
    IF junk >9 AND foo < 100 then foo = foo(dummy) OR 2
    IF junk > 99 and foo < 1000 THEN foo = foo(whatever) OR 4

(Not that the example above makes any sense as a recursive function.  It's just there to show the functionality where adding a parameter to the function name turned it into a recursive call, rather than a name, inside the function.)

And you'll still find examples in the wiki, or on the forums, or in old libraries and github repositories that haven't been updated to change to the new "fixed" format of:

Code: (Select All)
FUNCTION foo
    IF junk < 10 THEN tempfoo = tempfoo OR 1
    IF junk >9 AND foo < 100 then tempfoo = tempfoo OR 2
    IF junk > 99 and foo < 1000 THEN tempfoo = tempfoo OR 4
    foo = tempfoo

END FUNCTION
Reply


Messages In This Thread
Meta Commands - by NasaCow - 11-16-2022, 03:41 AM
RE: Meta Commands - by mnrvovrfc - 11-16-2022, 04:49 AM
RE: Meta Commands - by NasaCow - 11-16-2022, 11:44 AM
RE: Meta Commands - by SMcNeill - 11-16-2022, 04:06 PM
RE: Meta Commands - by mnrvovrfc - 12-06-2022, 04:08 AM
RE: Meta Commands - by bplus - 11-16-2022, 05:13 AM
RE: Meta Commands - by NasaCow - 11-16-2022, 11:47 AM
RE: Meta Commands - by TerryRitchie - 11-16-2022, 04:28 PM
RE: Meta Commands - by SMcNeill - 11-16-2022, 04:48 PM
RE: Meta Commands - by TerryRitchie - 11-16-2022, 06:50 PM
RE: Meta Commands - by RhoSigma - 11-16-2022, 05:22 PM
RE: Meta Commands - by bplus - 11-16-2022, 05:33 PM
RE: Meta Commands - by mnrvovrfc - 11-16-2022, 06:36 PM
RE: Meta Commands - by SMcNeill - 12-06-2022, 05:26 AM
RE: Meta Commands - by mnrvovrfc - 12-06-2022, 06:07 AM
RE: Meta Commands - by SMcNeill - 12-06-2022, 07:12 AM



Users browsing this thread: 9 Guest(s)