Compilation I guess...
Root / Submissions / [.]
12Me21Created:
SB programs are compiled from top to bottom.
During Compilation:
When an expression is encountered:
-If it is a numeric expression containing only constants (numbers, # constants, and PI()) and constant operators (- ! NOT * / DIV MOD + - << >> AND XOR OR), it is evaluated and replaced with the result.
DATA only allows constant expressions and plain strings, otherwise an error occurs.
OPTION STRICT enables strict mode for the rest of the program
OPTION DEFINT enables integer mode for the rest of the program (unsuffixed variables default to integer type)
When a variable is encountered (when not being created in VAR):
-If inside a function, and no global or local variable with that name exists yet, a local variable is created (if in strict mode, an error happens)
-If outside a function, and no global variable with that name exists yet, a global variable is created (if in strict mode, an error happens)
When a variable is created:
-If it has no type suffix, it becomes a real type (unless integer mode is enabled, when it becomes an integer)
-# type suffix creates a real
-% type suffix creates an integer
-$ type suffix creates a string
-[...] creates an array with up to 4 dimensions
-Numbers are initialized to 0
-Strings are ""
-Arrays are ???
When VAR is encountered:
-If inside a function definition, an error occurs if a local variable exists with the same name, otherwise a local variable is created
-If outside a function, an error occurs if a global variable exists with the same name, otherwise a global variable is created
-Variables are created.
-Numbers are initialized to 0
-Strings are ""
-Arrays are ???
During Execution:
USE:
-compiles the code in a slot.
EXEC:
-compiles and runs the code in a slot.
When VAR is executed:
-Values are assigned to string/number variables
-Arrays are initialized
Replying to:DFrost
I just thought about this:
if you create a program and load it in a different slot and use slot 0 to USE it, wouldn't it be a tad faster because it's compiling before execution instead of during it?
compilation happens to dirty program slots when USE, RUN, or EXEC are used
how does this change anything...? if anything, you're just delaying compilation.
if you mean in a larger context such as
: load A and B
: execute A
: execute B
then umm... maybe you can save some time between A and B by USEing B at the start of A, I guess.
Replying to:DFrost
I just thought about this:
if you create a program and load it in a different slot and use slot 0 to USE it, wouldn't it be a tad faster because it's compiling before execution instead of during it?
I mean this:
<slot 0> use 1'compiling slot 1 <slot 1> 'a whole bunch of code gets completely compiled instead of line by line COMMON DEF RANDOM() DIM RAND[20,20] FOR I = 0 TO 19 FOR J = 0 TO 19 RAND[I,J]=RNDF() NEXT NEXT RETURN RAND ENDWhen ran, SB compiles line by line which is slower while running, but if all of it is compiled at the beginning of execution, wouldn't it trade(some of) the execution time for a function call to the beginning of execution? it's hard to explain what I mean easily
Replying to:DFrost
I just thought about this:
if you create a program and load it in a different slot and use slot 0 to USE it, wouldn't it be a tad faster because it's compiling before execution instead of during it?
maybe it's hard to explain because you're wrong ww?
Programs are compiled in whole at the start of execution.
I don't know where you got the belief that it 'compiles' each line as it is executed.
Replying to:DFrost
I just thought about this:
if you create a program and load it in a different slot and use slot 0 to USE it, wouldn't it be a tad faster because it's compiling before execution instead of during it?
i might be an oxymoron!