Σάββατο 26 Ιανουαρίου 2019

Revision 6 Version 9.7

A bug removed. The bug happen when a global array had the same name with a local variable:

\\ the bug was in line k$(i)="ok", with an exit from For block. Now works fine
k=2
global k$(k)
for i=0 to k-1 {
      k$(i)="ok"
}
Print k$()

In the second example the bug was more drastic, because not only lost the k( in line k(i)=100, but raise error for no subroutine found (expected k(i) to be a subroutine). Now works fine

k=2
global k(k)
for i=0 to k-1 {
      k(i)=100
}
Print k()


Look this example. We have k$() as global and we have a local static group k$ which return a string value and take one argument, so we can read k$(100) as the value of the group. Interpreter, first search for a local array. Here there is no k$() as local array. So interpreter search for an inventory, k, but no inventory exist, then search for k$ for group, and so found one, so process the value function of group. To use the array we have to use the Set command, which change namespace to global for this line of code. Because we can read the local variables in the Set statement we have to use the stack of values to pass a value (when interpreter execute the Set statement change temporary the namespace to global, but use the same stack of values, as the one in current namespace).

If we make the group k$ as global (use global before group statement) then we get an error because the k$( in Print k$(100) founded as global array, and not as a group. The same happen in the next example with inventory. Arrays come first in search (a hash table used inside).

global k$(10)="*"
group k$ {
      value (a) {
            ="****"
      }
}
Print k$(100)
push 3
set print k$(number)

This is an example like the previous one, but now we have an inventory k, it is a local one:

global k$(10)="*"
inventory k= 100:="****"
Print k$(100)
push 3
set print k$(number)



Δεν υπάρχουν σχόλια:

Δημοσίευση σχολίου

You can feel free to write any suggestion, or idea on the subject.