richhickey/clojure-clr

Cultures and formatting

Closed this issue · 3 comments

Hi,

While following the Clojure wikibook, I found:

user=> 0.1
1

This is because my culture is set differently. For parsing program text culture should not be taken into account, and I managed to achieve this by changing LispReader.cs as follows:

656: radix = Int32.Parse( m.Groups[6].Value, System.Globalization.CultureInfo.InvariantCulture );
679: return (object)Double.Parse(s,System.Globalization.CultureInfo.InvariantCulture);

That works, i.e.

user=> 0.1
0,1

which looks weird but seems correct - problem is now that the output is still formatted according to culture conventions. Again, a REPL should not take culture into account when printing I guess (especially since comma is reserved for tuple syntax so i just looks weird), but I haven't been able to find where to fix this.

Kurt

I had another user working in the French locale point this out about two days ago.
As you point out, the reader is an easy fix and I'll be doing it in a moment.

I still have to track down the printer situation. Some of that is tricky because .ToString is called indiscriminately in .CLJ code.

The latest commit has a fix for the printing.

Works:

user=> 1.2e-4
0.00012
user=> 0.00100
0.001