micro(A)v11 - Printable Version +- QB64 Phoenix Edition (https://staging.qb64phoenix.com) +-- Forum: QB64 Rising (https://staging.qb64phoenix.com/forumdisplay.php?fid=1) +--- Forum: QBJS, BAM, and Other BASICs (https://staging.qb64phoenix.com/forumdisplay.php?fid=50) +--- Thread: micro(A)v11 (/showthread.php?tid=1823) |
RE: micro(A)v11 - mnrvovrfc - 08-14-2023 I was trying to find the post months ago by dbox where he says "JS <> JavaScript". Quote:Yeah if this is about User Defined Functions in MicroA, yes go for it man! Love to see that no matter how you get there. THIS IS A PROPOSAL: I guess it's just reserving global variables that could be used inside a "func", and are called into play for something like this: Code: (Select All) var one, two or have a keyword (I call "param") to represent the special variables: Code: (Select All) param callmexa, callmeya, callmeps, yadaone, yadatwo, foobar, elisa4 The problem is those special variables might have to be given types also. Not assume they are all "var". :/ Let me try to explain to see if Aurel doesn't get confused easily. Define variables as usual but that cannot be used in main-level code. Which would require a special keyword. Maybe (with fake "paramv" and "params" keywords) have something like this: Code: (Select All) paramv callmexa, callmeya The only difference between "callmexa" and "a" is that "callmexa" can be accessed only in "callme" subprogram because that subprogram is specifically calling for it. If there's another func and it's not referring to "callmexa" then that parameter cannot be used. The advantage of a system like this is that it could be restricted to conserve RAM, say to five "var", five "str" and five "ptr" variables. If you want more you beg Aurel for micro(A) code, modify it to support more and recompile. Otherwise work on something that looks more like Perl or MS-DOS batch language or "bash" script, but which could be potentially confusing and difficult to debug. RE: micro(A)v11 - aurel - 08-15-2023 Quote:Let me try to explain to see if Aurel doesn't get confused easily.I am already confused But looks to me that you are not sure and thanks for proposal there is trick for local variable is it is not problem in declaration then in execution i can easy add this : Code: (Select All) myFN() myFN(a,b,c) so function must be declared or autoDeclared RE: micro(A)v11 - bplus - 08-15-2023 For my Interpreter, oh, I plan on having a Subroutine "Call Subname;arg1;arg2;arg3..." For Functions I will have a Function Func[functionName, arg1, arg2, arg3] Both the Call routine and the Func[ ] function will lookup the 1st argument which is block name for lines of code to execute the sub or function. So in a recursive call to my code executer something like Run( codeblock$, parameters$) will split the codeblock$ out to string array of program lines and split parameters$ string to string array of arguments to which matching values will be assigned from the actual call or Func[] call. I also probably will have to store the variable table for current code block on stack before call and pull it down again and update byref variables in that variable table before exit the sub or function call. Shared variables? probably need a separate SHARED variable table and consult that first when checking variable assignments. Got all that? Tricky as hell I've been thinking off and on about it for 2 years! RE: micro(A)v11 - aurel - 08-15-2023 Mark If you simple have mid$ function which is as you know with pre-defined numbers of arguments in MID$ they are 3 ( string, position, size) but in Function we don't know number of arguments...right? BUT IF function is declared let say DEF_FN fnName( arg1, arg2, arg3 ,....) or auto - declared or pre-processed then we are on the HORSE or horze he he i will blow --,my bad english ..sorry so what is the first in pseudo-code: 1. Code: (Select All) IF nexttoken$ (pos+1 ) <> " ) " 2. extract arguments like strings and store it into string array or "argument list" count number of arguments -> nArgs Maybe use UDT to store data about function or use arrays i used arrays but UDT should be fine to... Code: (Select All) userFuncName$ ( index) = fnName$ did i miss something ? maybe some other members have some ideas? RE: micro(A)v11 - mnrvovrfc - 08-15-2023 I don't know what you are doing to keep track of variables in micro(A). But it would have to be done in one of two ways. An UDT which looks more or less like this: Code: (Select All) type vardecl This is just for starters and is only for example. "ident" is the name of the variable. "kind" must be called that way, not "type" since it's a reserved word in most modern BASIC's. This decides whether to use "var", "ptr" or "str" in micro(A). "isarray" then enables an external rule for a memory pool to attach to this element of this UDT. In other words, it could be zero for a regular variable in micro(A) and otherwise, the maximum number of elements in the array. "scope" is the important one here. It could be set to zero so all variables are global. The way to set it, however could be a pain. Some manuals like that for Free Pascal talk about "reference levels" which causes discouragement. But if the author of the interpreter expects it to be useful enough to allow nested calling of functions, this problem has to be attacked. This "scope" thing could help in checking to protect variables in another scope. The author of the interpreter could choose how to protect the global variables inside an user-written function. Could always do it, like in Python unless "global" keyword is offered. Now creating local variables should rely on scope. When the user-defined function exits, just search the variable table for candidates with the same scope and remove them. Please do not complicate the situation LOL by seeking to replicate "STATIC" technique in QuickBASIC/Qbasic/QB64. Must rely here on global variables that preserve value between function calls. Otherwise the suggestion is one I made earlier. Reserve a limited number of variables. Like five per type. They will be used only as parameters for the user-written functions. This is similar to how Perl and Powershell handle things. The drawback is that it limits having one user-written function from calling another one. The author of the interpreter doesn't want to keep a large amount of memory for variables that cannot be used in the main program. I was going to disturb bplus about this a few months ago. Keep 10 variables around to be used only for user-defined functions in "Oh" interpreter. Keep another 10 variables if you really want to be ambitious, and have one "Oh" interpreter instance call another instance. Which would bring about replicating COMMAND$. Those variables should not be used for any other purpose. They should be just volatile helpers like $1, $2, $3 etc. in "gawk" and Perl, like replaceable parameters in MS-DOS batch language. RE: micro(A)v11 - aurel - 08-16-2023 Hi mnr I will copy your reply to basic4us because i can't track on both forums RE: micro(A)v11 - aurel - 08-16-2023 Quote:I don't know what you are doing to keep track of variables in micro(A)That means that you never look into source code of micro(A) variable lookUp is by variableID ..id is Integer not string/name but focus here is functions with arguments it is not if they stored in same place where are global varibles Code: (Select All) example: RE: micro(A)v11 - aurel - 08-20-2023 Bing Reading Thread micro(A)v11 [/url] [url=https://staging.qb64phoenix.com/showthread.php?tid=1823]who is Bing RE: micro(A)v11 - mnrvovrfc - 08-20-2023 Right now "roquedrivel" is having problems trying to think out of strings, for a graphics program in micro(A). There would be more to offer if "print" statement could do a monospaced font. We keep forgetting to test if it supports UTF-8. RE: micro(A)v11 - aurel - 08-20-2023 What you mean under monospaced font another Font ? |