Too many parameters/locals bug

Anything QL Software or Programming Related.
User avatar
ql_freak
Gold Card
Posts: 354
Joined: Sun Jan 18, 2015 1:29 am

Re: Too many parameters/locals bug

Post by ql_freak »

Hi Steve,
stevepoole wrote: Sat Jun 17, 2023 9:15 pm ... Tested under QDOS on SGC, (but used to run ok on 128ko).

Define the main routine however you require !
Seems to be a nice trick! But it works because, SB-variables are different from C locals (see my example from c't magazine) and as Norman approved.

BTW: (At least) In Python it's possible, to achieve the same result, cause you can nest function definitions inside of function definitions. The inner functions have access to the local variables of the outer functions :-)

BUT YOU SHOULD USE THOSE TRICKS WITH CARE!


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 :-)
Derek_Stewart
Font of All Knowledge
Posts: 3975
Joined: Mon Dec 20, 2010 11:40 am
Location: Sunny Runcorn, Cheshire, UK

Re: Too many parameters/locals bug

Post by Derek_Stewart »

Hi,

I am a little confused by this problem, are you not mixing global variables up with loczl variables.

Also wrote quick Superbasic program to pass 13 variables to a procedure, with 13 local variables defined with the procedure:

Code: Select all

10 a=100: b=110: c=120: d=130: e=140
15 f=150: g=160: h=170: i=180: j=190
16 k=200: l=210: m=220
21 test a,b,c,d,e,f,g,h,i,j,k,l,m
30 :
40 DEFine PROCedure test(a1,b1,c1,d1,e1,f1,g1,h1,i1,j1,k1,l1,m1)
50    LOCal a,b,c,d,e,f,g,h,i,j,k,l,m
60    a=0: b=1: c=2: d=3: e=4
61    f=5: g=6: h=7: i=8: j=9
62    k=10: l=11: m=12
70    PRINT a1,b1,c1,d1,e1,f1,g1,h1,i1,j1,k1,l1,m1
71    PRINT a,b,c,d,e,f,g,h,i,j,k,l,m
80 END DEFine
All serms to work as expected in JS, Minerva and SMSQ/E


Regards,

Derek
stevepoole
Super Gold Card
Posts: 716
Joined: Mon Nov 24, 2014 2:03 pm

Re: Too many parameters/locals bug

Post by stevepoole »

Hi Derek,
No confusion in the program between Globals and Locals : Since Local variables are also local to ALL nested routines within the calling routine, (right down through the calling tree...).

The program worked ok under QDos on a 128ko JM. It is not needed at all with SMSQ/E, since the LOCals bug got fixed...
But the technique to return errors from deeply nested routines is still useful !

Regards, Steve.


Post Reply