Too many parameters/locals bug
- NormanDunbar
- Forum Moderator
- Posts: 2281
- Joined: Tue Dec 14, 2010 9:04 am
- Location: Leeds, West Yorkshire, UK
- Contact:
Too many parameters/locals bug
Does anyone remember the bug whereby if a SuperBASIC procedure or function had a total of 10 (I think) or more parameters and locals, it would corrupt SuperBASIC? I was reading an old DJToolkit manual this morning -- don't ask -- and came across a comment from myself about it. I was wondering what exactly caused this problem. Does anyone know? It's no doubt already fixed in SMSQ so looking in the sources probably won't help. It's not urgent, or causing any problems, I'm just curious.
Cheers,
Norm.
Cheers,
Norm.
Why do they put lightning conductors on churches?
Author of Arduino Software Internals
Author of Arduino Interrupts
No longer on Twitter, find me on https://mastodon.scot/@NormanDunbar.
Author of Arduino Software Internals
Author of Arduino Interrupts
No longer on Twitter, find me on https://mastodon.scot/@NormanDunbar.
Re: Too many parameters/locals bug
From one of Simon Goodwin's bugs articles:
“MG” SuperBasic has been thoroughly spring-cleaned. You can use any number of parameters and LOCALs in a procedure or function. Previous versions of the Basic allowed only enough space for nine such names. If you used more, the program could lock up or be corrupted by the appearance of spurious PRINT keywords in place of names towards the end of the program. That knowledge may help you to spot program listings which were improved by their authors, untested, before publication.
--
All things QL - https://dilwyn.qlforum.co.uk/index.html
All things QL - https://dilwyn.qlforum.co.uk/index.html
- NormanDunbar
- Forum Moderator
- Posts: 2281
- Joined: Tue Dec 14, 2010 9:04 am
- Location: Leeds, West Yorkshire, UK
- Contact:
Re: Too many parameters/locals bug
Thanks Dilwyn. I was wondering if the problem was caused by assuming "nobody will need more than 9 parameters or locals" and it seems that that was indeed the cause of the error.
Cheers,
Norm.
Cheers,
Norm.
Why do they put lightning conductors on churches?
Author of Arduino Software Internals
Author of Arduino Interrupts
No longer on Twitter, find me on https://mastodon.scot/@NormanDunbar.
Author of Arduino Software Internals
Author of Arduino Interrupts
No longer on Twitter, find me on https://mastodon.scot/@NormanDunbar.
-
- Super Gold Card
- Posts: 717
- Joined: Mon Nov 24, 2014 2:03 pm
Re: Too many parameters/locals bug
Hi Norm,
There was a fix for the LOCals bug :
erzero=one: if erzero<>0: print 'error': stop
DEF FUnction one
Local (nine elements).
erone=two: RETurn erone
end def
DEF FUNCtion two
Local (another nine elements)
ertwo=main: RETurn ertwo
end def
DEF FUNCtion main etc
You could nest as many dummy routines as you needed locals in your main program....
I used this technique many times without problems.
Note the error returns needed, to get back up through the calls !
Regards, Steve.
_________________
There was a fix for the LOCals bug :
erzero=one: if erzero<>0: print 'error': stop
DEF FUnction one
Local (nine elements).
erone=two: RETurn erone
end def
DEF FUNCtion two
Local (another nine elements)
ertwo=main: RETurn ertwo
end def
DEF FUNCtion main etc
You could nest as many dummy routines as you needed locals in your main program....
I used this technique many times without problems.
Note the error returns needed, to get back up through the calls !
Regards, Steve.
_________________
- NormanDunbar
- Forum Moderator
- Posts: 2281
- Joined: Tue Dec 14, 2010 9:04 am
- Location: Leeds, West Yorkshire, UK
- Contact:
Re: Too many parameters/locals bug
Interesting, very interesting! And quite strange too.
I'm not having problems with this, I was just wondering what had been the cause. But thanks for the workaround Steve.
Cheers,
Norm.
I'm not having problems with this, I was just wondering what had been the cause. But thanks for the workaround Steve.
Cheers,
Norm.
Why do they put lightning conductors on churches?
Author of Arduino Software Internals
Author of Arduino Interrupts
No longer on Twitter, find me on https://mastodon.scot/@NormanDunbar.
Author of Arduino Software Internals
Author of Arduino Interrupts
No longer on Twitter, find me on https://mastodon.scot/@NormanDunbar.
Re: Too many parameters/locals bug
Hi Steve,
Regards
Peter
Albeit I don't fully understand your (not complete?) example, I think it's because local variables in SuperBASIC are not really local variables as in other languages (e.g. C or Python). See the following example:stevepoole wrote: ↑Thu Jun 15, 2023 10:16 pm There was a fix for the LOCals bug :
erzero=one: if erzero<>0: print 'error': stop
...
Code: Select all
100 REMark demo for visibility (c't 11/1984, Florian Sachse)
110 :
120 o%=4:LIST#o%
130 :
140 REMark main program
150 :
160 test_text$ = 'From main program'
170 test1
180 test2
190 :
200 DEFine PROCedure test1
210 PRINT#o%,'Which variable is visible(?): ';test_text$
220 END DEFine
230 :
240 DEFine PROCedure test2
250 LOCal test_text$
260 :
270 test_text$ = 'From Procedure "test2"'
280 test1
290 END DEFine
300 :
310 :
320 REMark Output:
330 :
Which variable is visible(?): From main program
Which variable is visible(?): From Procedure "test2"
Peter
http://peter-sulzer.bplaced.net
GERMAN! QL-Download page also available in English: GETLINE$() function, UNIX-like "ls" command, improved DIY-Toolkit function EDLINE$ - All with source. AND a good Python 3 Tutorial (German) for Win/UNIX
GERMAN! QL-Download page also available in English: GETLINE$() function, UNIX-like "ls" command, improved DIY-Toolkit function EDLINE$ - All with source. AND a good Python 3 Tutorial (German) for Win/UNIX
- NormanDunbar
- Forum Moderator
- Posts: 2281
- Joined: Tue Dec 14, 2010 9:04 am
- Location: Leeds, West Yorkshire, UK
- Contact:
Re: Too many parameters/locals bug
Hi Peter,
SuperBASIC is interesting in this respect. I have a stalled project at https://github.com/NormanDunbar/C68Port -- the SBLocals directory has a C68 source file which emulates thecway the SuperBASIC handles locals -- basically, locals are visible in the FN/PROC which declared them and in any called FN/PROCs called from there, no matter how deep the call tree is!
The tests directory has a number of test programs to be sure my codecworks.
(If anyone is even slightly interested!)
Cheers,
Norm.
SuperBASIC is interesting in this respect. I have a stalled project at https://github.com/NormanDunbar/C68Port -- the SBLocals directory has a C68 source file which emulates thecway the SuperBASIC handles locals -- basically, locals are visible in the FN/PROC which declared them and in any called FN/PROCs called from there, no matter how deep the call tree is!
The tests directory has a number of test programs to be sure my codecworks.
(If anyone is even slightly interested!)
Cheers,
Norm.
Why do they put lightning conductors on churches?
Author of Arduino Software Internals
Author of Arduino Interrupts
No longer on Twitter, find me on https://mastodon.scot/@NormanDunbar.
Author of Arduino Software Internals
Author of Arduino Interrupts
No longer on Twitter, find me on https://mastodon.scot/@NormanDunbar.
Re: Too many parameters/locals bug
Sounds interesting, especially C68Port (Digital Precision?). Does this finally work? I have had bought it, but It didn't work. At least not with my programs.NormanDunbar wrote: ↑Fri Jun 16, 2023 10:05 pm ... the SBLocals directory has a C68 source file which emulates thecway the SuperBASIC handles locals ...
...
(If anyone is even slightly interested!)
Regards
Peter
http://peter-sulzer.bplaced.net
GERMAN! QL-Download page also available in English: GETLINE$() function, UNIX-like "ls" command, improved DIY-Toolkit function EDLINE$ - All with source. AND a good Python 3 Tutorial (German) for Win/UNIX
GERMAN! QL-Download page also available in English: GETLINE$() function, UNIX-like "ls" command, improved DIY-Toolkit function EDLINE$ - All with source. AND a good Python 3 Tutorial (German) for Win/UNIX
- NormanDunbar
- Forum Moderator
- Posts: 2281
- Joined: Tue Dec 14, 2010 9:04 am
- Location: Leeds, West Yorkshire, UK
- Contact:
Re: Too many parameters/locals bug
Hi Peter,
As for the original CPort, it did work -- sort of -- but If I remember correctly, there were a couple of programs written to massage the generated C code to make it actually work a bit better.
Cheers,
Norm.
Well, Digital Precision's program was Cport, mine -- the stalled project -- is C68Port. I'm attempting to write a version of SuperBASIC to C68 style C code, whether or not I get it finished remains to be seen. I'm afraid I have many started but not finished projects these days. Something to do with writing books! When I started writing it, I decided to work out a manner in which I could get a proper emulation of how SuperBASIC handles locals. I know I got it working for integers and floats, and arrays of the same as well as strings. I thing I stalled somewhere/somehow on arrays of strings. I'd have to check though.
As for the original CPort, it did work -- sort of -- but If I remember correctly, there were a couple of programs written to massage the generated C code to make it actually work a bit better.
Cheers,
Norm.
Why do they put lightning conductors on churches?
Author of Arduino Software Internals
Author of Arduino Interrupts
No longer on Twitter, find me on https://mastodon.scot/@NormanDunbar.
Author of Arduino Software Internals
Author of Arduino Interrupts
No longer on Twitter, find me on https://mastodon.scot/@NormanDunbar.
-
- Super Gold Card
- Posts: 717
- Joined: Mon Nov 24, 2014 2:03 pm
Re: Too many parameters/locals bug
Hi QL_Freak,
Herewith, a complete 'demo' program allowing more than nine locals in a function, with the possibility to escape on an error.....
It will work with procedures too. Tested under QDOS on SGC, (but used to run ok on 128ko).
Define the main routine however you require !
Steve. _______________________________________________________
Herewith, a complete 'demo' program allowing more than nine locals in a function, with the possibility to escape on an error.....
It will work with procedures too. Tested under QDOS on SGC, (but used to run ok on 128ko).
Define the main routine however you require !
Steve. _______________________________________________________