On Mon, 12 Mar 2018, Sven Schreiber wrote:
> Am 12.03.18 um 08:30 schrieb Riccardo (Jack) Lucchetti
>
> > I'm sorry I'm chiming in only at this stage, but I find the whole issue
> > quite confusing. In my view, Hansl should not aim at being too clever with
> > strings. There already are many tools that are much better at that than
> > Hansl will ever be (Python of course springs to mind). Maybe I'm being a
> > little too conservative here, but in my eyes a Boolean expression is
> > something that should unambiguously map to 0 or non-zero. True, "if
foo"
> > (foo being a string) can be interpreted as shorthand for "if
strlen(foo)",
> > but then the problem arises on cases like
> >
> > if foo || bar
> > if foo && bar
> > if foo * bar
> > if foo + bar
> > if !foo
> >
> > ("bar" being some arbitrary variable, such as a string but also
possibly a
> > scalar, a matrix etc), etcetera, in which we would have first to guess
> > whether the intended outcome is Boolean or not and then act accordingly.
> >
> > Too complicated IMO. If it weren't for backward compatibility, I'd ban
"if
> > <string>" altogether, but at this point I would guess we could allow
"if
> > foo" (where "foo" is a named string, but not something that
evaluates to a
> > string) for historical reasons, but no more than
>
> Yes, I think that s the conclusion we’ve reached as well. And
> because it was undocumented “if foo” will also be banned after
> the respective function packages (mine, perhaps Oleh’s?) have
> been adjusted. At least that’s my interpretation of the
> discussion.
Hmm, I've just added a compile-time switch in genmain.c,
STR_AS_BOOL, whereby one can turn off interpretation of strings as
boolean values. In my working copy I've flipped this switch and run
all my tests (all addons, all function packages, numerous test
scripts gathered over the years), and I'm not seeing any failures.
Are we sure that strings are used as booleans in any packages? If
so, could you give me an example? (It may be that there's some
"backdoor" way a string could get taken as a boolean that has
escaped my notice and has not really been turned off.)
Allin