Melchior FRANZ wrote:
> Unfortunately, I can't avoid the silly double-0. No idea why.

As you pointed out on the IRC channel (which more folks should be on,
it's kinda fun sometimes), this is a Nasal bug.  Or two, actually.

The simple bug is that the string "-" converts to a numerical zero due
to the way the number parser works.  That should be easy to fix.

But it exposes a nastier issue in the code generator.  Nasal's binary
format uses a table of scalar constants ("foo", 1.234, etc...) that
appear in each code block.  To save space, it uses a hash table to
eliminate duplicated constants.  But to a Nasal hash table, all
"equal" constants look alike.  So in fact if you write a source with
something like:

   a = "0"; b = "0.0"; c = 0; d = "-";

... then these four constants (three strings and one number) will all
turn into exactly the *same* *thing* in the generated code (which one
in particular gets chosen depends on which one the code generator
spits out first).  Most of the time, that's benign and invisible,
except where string conversions are an issue.

Anyway, I need to fix this to use a true identity test instead of a
standard nasal hash table in the code generator.  Gimme a while to
play with it.  Fun bug, though.

For now, the workaround is what you already discovered: don't use a
constant in the code with a numerical value of zero.  Use something
like "a-" instead, and strip off the leading "a" at runtime.

Andy


_______________________________________________
Flightgear-devel mailing list
Flightgear-devel@flightgear.org
http://mail.flightgear.org/mailman/listinfo/flightgear-devel
2f585eeea02e2c79d7b1d8c4963bae2d

Reply via email to