I have a problem with the arrays: currently, character and numerical
indexes are implemented as hashes.
This means that NASL will be efficient on code like this:
v[-17] = "something";
v[66666] = "AAA";
v["A"] = "B";
Unfortunately, this break the index order in numerical arrays.
Implementing push() or max_index() is a pain in the back, and
make_list() is broken with array arguments.
e.g.
for (i = 1; i < 20; i++) v[i] = i;
w = make_list('zero', v, 'infinite');
for (i = 1; w[i]; i ++) display(w[i], '\n');
This works fine as long as n is small (< 7), but if you change the
loop to go to 20, the list is shuffled.
As we cannot have "the butter and the money of the butter", I suggest
that we use C arrays for the numerical indexes.
This means that the base index will be 0 (maybe I'll implement
something like $[. in Perl), that negative indexes will not be
supported (at least in the first version), and that access to big
indexes will waste much memory.
On the other hand, it will be easy to keep to implement things like
pop and push, max_index, the magical PHP empty index (v[]=next_value;)
etc.
There is also another vicious problem with those hashed arrays: they
are used to transfer parameters to functions.
Currently, this does not work:
x=NULL; # undefined the variable
display('One ', x, ' Two');
You'll never see two because display stops at the first undefined
variable. This is rather a design flaw in the interface and
a bug in nasl_display, anyway, it would be simpler with C 0-based
arrays.
BTW, should I start writing a NASL2 reference manual?
--
mailto:arboi@bigfoot.com
GPG Public keys: http://michel.arboi.free.fr/pubkey.txt
http://michel.arboi.free.fr/ http://arboi.da.ru/
FAQNOPI de fr.comp.securite : http://faqnopi.da.ru/
indexes are implemented as hashes.
This means that NASL will be efficient on code like this:
v[-17] = "something";
v[66666] = "AAA";
v["A"] = "B";
Unfortunately, this break the index order in numerical arrays.
Implementing push() or max_index() is a pain in the back, and
make_list() is broken with array arguments.
e.g.
for (i = 1; i < 20; i++) v[i] = i;
w = make_list('zero', v, 'infinite');
for (i = 1; w[i]; i ++) display(w[i], '\n');
This works fine as long as n is small (< 7), but if you change the
loop to go to 20, the list is shuffled.
As we cannot have "the butter and the money of the butter", I suggest
that we use C arrays for the numerical indexes.
This means that the base index will be 0 (maybe I'll implement
something like $[. in Perl), that negative indexes will not be
supported (at least in the first version), and that access to big
indexes will waste much memory.
On the other hand, it will be easy to keep to implement things like
pop and push, max_index, the magical PHP empty index (v[]=next_value;)
etc.
There is also another vicious problem with those hashed arrays: they
are used to transfer parameters to functions.
Currently, this does not work:
x=NULL; # undefined the variable
display('One ', x, ' Two');
You'll never see two because display stops at the first undefined
variable. This is rather a design flaw in the interface and
a bug in nasl_display, anyway, it would be simpler with C 0-based
arrays.
BTW, should I start writing a NASL2 reference manual?
--
mailto:arboi@bigfoot.com
GPG Public keys: http://michel.arboi.free.fr/pubkey.txt
http://michel.arboi.free.fr/ http://arboi.da.ru/
FAQNOPI de fr.comp.securite : http://faqnopi.da.ru/