Re: [NASL2] Auto-conversion with + and -

Michel Arboi <[email protected]>
Newsgroups gmane.comp.security.nessus.devel
Organization Compilo ergo sum
Message-ID <[email protected]>
"Jim Cervantes" <[email protected]> writes:

> When a programmer chooses an operator, she will mean either addition or
> string concatenation, without any ambiguity in mind.

A way to do it could be to force the types of the arguments with int()
or string()
Unfortunately, string() does more than converting its arguments to
ASCII: it interprets escape sequences in "impure strings".

> I would recommend disambiguating the meaning of your operators.  Use '+' to
> mean addition and something else to mean string concatenation.

But many scripts will be broken then.
string() could be used to concatenate strings, with the problem with
"impure" string. Maybe we just add a "strcat" function ?
(this is simpler than adding a Perl-like dot operator)

> "123" + "7"	produces 130

This can be done with int("123") + int("7")

Here is my proposal, for the moment: I add a BIG warning when + or -
arguments are converted. We wait for a while, and if all the current
scripts are OK, we remove the "auto conversion" and returns an error.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.