mozart/mozart2 — pull request #120 by eregon (2013-11-30 13:09:16+00:00)
Title: negative numbers should be represented as '~'#{Abs Number}

See #119. An easier test case is `{Browse ~5}` (which gives `~5`).

Personally I would prefer Oz to use `-` as about every other language out there, but if I recall this choice is due to an issue with the parser. Is that still an issue, is it ambiguous to recognize `-N` versus `A - B`?

In Mozart 1, `float2buffer` and `smallInt2buffer` both take a `char sign` and are used in different places with `~` and `-` (respectively `term2Buffer`and `virtualString2buffer`).

`virtualString2buffer` seems only used (in Mozart 1) in `OZ_virtualStringToC` and in `OZ_BI_define(BIvsToBs,3,1)` in `builtins.cc`.

So `{Browse 'we are in '#~3}` gives `we are in -3` when checking the virtual string representation checkbox in the Browser.
This case is handled in Mozart 2 as well, as `VirtualString.toString` explicitely convert `~` to `-`.

Anyway, it is probably for the best the string representation of a number is similar to its representation as a literal.

`float2buffer` (https://github.com/mozart/mozart/blob/master/platform/emulator/foreign.cc#L648-L687) also takes care of adding ".0" if not present in the output, mozart2 should probably do it as well such as `~5` can only be a negative SmallInt (and not possibly a Float). I am searching for better ways to do that than parsing the string outputted by the default C++ conversion to string. If you have any idea please share!