
Hi, A small annoyance some users outside english speaking countries usually experiment when learning programming languages is that real numbers use a '.' instead of ','. Of course, that is not such a problem except for the inconsistence between computer and free hand notation. Do you think 'read' (actually, 'readsPrec'?) could be made to also read the international convention (ie., read "1,5" would also work besides read "1.5")? I'm happy to finaly use a language where I can use words of my language to name variables, so I wonder if we could also make that step. Thanks, Maurício

Mauricio wrote:
Hi,
A small annoyance some users outside english speaking countries usually experiment when learning programming languages is that real numbers use a '.' instead of ','. Of course, that is not such a problem except for the inconsistence between computer and free hand notation.
Do you think 'read' (actually, 'readsPrec'?) could be made to also read the international convention (ie., read "1,5" would also work besides read "1.5")? I'm happy to finaly use a language where I can use words of my language to name variables, so I wonder if we could also make that step.
Isn't it locale dependent? If it isn't, it should be. Try setting your locale right and see if things work. At least awk work fine that way. Although I don't like too much that kinda stuff, I usually set the locale to C so I keep all my programs behaving consistently. I have problems with that stuff before (a file generated by an awk script had , instead of . and that would confuse other computers with a different locale).

No, it is not. Strings created by show are always supposed to be readable by read, no matter which system used 'show' and which system is using 'read'. Maurício Rafael C. de Almeida a écrit :
Mauricio wrote:
Hi,
A small annoyance some users outside english speaking countries usually experiment when learning programming languages is that real numbers use a '.' instead of ','. Of course, that is not such a problem except for the inconsistence between computer and free hand notation.
Do you think 'read' (actually, 'readsPrec'?) could be made to also read the international convention (ie., read "1,5" would also work besides read "1.5")? I'm happy to finaly use a language where I can use words of my language to name variables, so I wonder if we could also make that step.
Isn't it locale dependent? If it isn't, it should be. Try setting your locale right and see if things work. At least awk work fine that way.
Although I don't like too much that kinda stuff, I usually set the locale to C so I keep all my programs behaving consistently. I have problems with that stuff before (a file generated by an awk script had , instead of . and that would confuse other computers with a different locale).

Wouldn't that make it hard to parse lists of floats? On Tue, 2008-09-16 at 09:29 -0300, Mauricio wrote:
Hi,
A small annoyance some users outside english speaking countries usually experiment when learning programming languages is that real numbers use a '.' instead of ','. Of course, that is not such a problem except for the inconsistence between computer and free hand notation.
Do you think 'read' (actually, 'readsPrec'?) could be made to also read the international convention (ie., read "1,5" would also work besides read "1.5")? I'm happy to finaly use a language where I can use words of my language to name variables, so I wonder if we could also make that step.
Thanks, Maurício
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

Maybe. Doubles 'show' function always print something after the decimal separator, so 'show [doubles]' is easy to parse but difficult for human reading. It would be nice to have a space between elements of a shown list, though. It's an annoyance, but internationalization is really great, I think it deserves the effort. Best, Maurício Tilo Wiklund a écrit :
Wouldn't that make it hard to parse lists of floats?
On Tue, 2008-09-16 at 09:29 -0300, Mauricio wrote:
Hi,
A small annoyance some users outside english speaking countries usually experiment when learning programming languages is that real numbers use a '.' instead of ','. Of course, that is not such a problem except for the inconsistence between computer and free hand notation.
Do you think 'read' (actually, 'readsPrec'?) could be made to also read the international convention (ie., read "1,5" would also work besides read "1.5")? I'm happy to finaly use a language where I can use words of my language to name variables, so I wonder if we could also make that step.
Thanks, Maurício
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
------------------------------------------------------------------------
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

On 16 Sep 2008, at 16:29, Mauricio wrote:
I'm happy to finaly use a language where I can use words of my language to name variables, so I wonder if we could also make that step.
Really? There is a bunch of languages (like "Glagol") that use words of Russian language as keywords; AFAIK there aren't any Russian programmer who uses them. I've always felt sorry for English-speaking programmers: they HAVE to use the same words as keywords and as usual talking words at the same time.

I'm happy to finaly use a language where I can use words of my language to name variables, so I wonder if we could also make that step.
Really?
There is a bunch of languages (like "Glagol") that use words of Russian language as keywords; AFAIK there aren't any Russian programmer who uses them. I've always felt sorry for English-speaking programmers: they HAVE to use the same words as keywords and as usual talking words at the same time.
Here I totally aggree with you. It's great that I can use words in my language for variables, but the same would be really annoying if the same was true for keywords. Best, Maurício

Mauricio wrote:
Do you think 'read' (actually, 'readsPrec'?) could be made to also read the international convention (ie., read "1,5" would also work besides read "1.5")? I'm happy to finaly use a language where I can use words of my language to name variables, so I wonder if we could also make that step.
That would be quite problematic in combination with lists, is read "[1,2,3,4]" == [1,2,3,4] or read "[1,2,3,4]" == [1.2, 3.4] Or something else? Localized reading should be somewhere else, perhaps related to Locales. As an aside, this is one of the (many) places where Haskell has made the right choice. In other languages such as Java input functions suddenly break when the user has a different locale setting. While for user input this might be desired, in my experience much of the i/o a program does is with well defined file formats where changing '.' to ',' just shouldn't happen. Twan

Do you think 'read' (actually, 'readsPrec'?) could be made to also read the international convention (ie., read "1,5" would also work besides read "1.5")? I'm happy to finaly use a language where I can use words of my language to name variables, so I wonder if we could also make that step.
That would be quite problematic in combination with lists, is
read "[1,2,3,4]" == [1,2,3,4]
or
read "[1,2,3,4]" == [1.2, 3.4]
Or something else?
As of today, at least in ghc, show ([1,2,3]::[Double]) will always produce "[1.0,2.0,3.0]". Since the requirement for read is to read what is produced by show, that would not be a problem.
Localized reading should be somewhere else, perhaps related to Locales.
No! If we had that, string from a program would not be readable by some program running in other machine, or other locale. As, actually, you describe below. Show and Read are for programs reading, not for user reading. That's a work for Pango :)
As an aside, this is one of the (many) places where Haskell has made the right choice. In other languages such as Java input functions suddenly break when the user has a different locale setting. While for user input this might be desired, in my experience much of the i/o a program does is with well defined file formats where changing '.' to ',' just shouldn't happen.
Best, Maurício

On 2008-09-17, Mauricio
Localized reading should be somewhere else, perhaps related to Locales.
No! If we had that, string from a program would not be readable by some program running in other machine, or other locale. As, actually, you describe below. Show and Read are for programs reading, not for user reading. That's a work for Pango :)
UI can be done with text, and in any case includes text and there should be some nice way to localize that. The locale system is the standard way to do that on Unix. These strings are not meant for program-to-program communication, whereas read and show are. IMAO, it's bloody well stupid to use commas for either the decimal separator or the thousands separator, as it has a well established role in separating the items in a list that conflicts with this. While a thousands separator can improve readability, it's not strictly necessary. OTOH, a decimal separator is necessary. As the comma's not usable, that leaves us with the decimal point, and no thousands separator. Lo and behold, that's exactly what Haskell uses. -- Aaron Denney -><-

On 2008 Sep 17, at 14:38, Aaron Denney wrote:
On 2008-09-17, Mauricio
wrote: Localized reading should be somewhere else, perhaps related to Locales.
No! If we had that, string from a program would not be readable by some program running in other machine, or other locale. As, actually, you describe below. Show and Read are for programs reading, not for user reading. That's a work for Pango :)
While a thousands separator can improve readability, it's not strictly necessary. OTOH, a decimal separator is necessary. As the comma's not usable, that leaves us with the decimal point, and no thousands separator. Lo and behold, that's exactly what Haskell uses.
There are languages which ignore _ in numbers, allowing it to be used as a thousands separator if desired. ghc currently parses "1_234" as <1:number> <_234:symbol> and I'm tempted to wonder if anything depends on it. -- brandon s. allbery [solaris,freebsd,perl,pugs,haskell] allbery@kf8nh.com system administrator [openafs,heimdal,too many hats] allbery@ece.cmu.edu electrical and computer engineering, carnegie mellon university KF8NH

Do you think 'read' (actually, 'readsPrec'?) could be made to also read the international convention (ie., read "1,5" would also work besides read "1.5")?
(...)
IMAO, it's bloody well stupid to use commas for either the decimal separator or the thousands separator, as it has a well established role in separating the items in a list that conflicts with this. (...)
After 10 years of professional experience, I'm getting used to the fact that almost every time someone says my idea is stupid I'm going in the right direction. Linux, firefox… And know everybody in the office uses nothing else. "It's stupid to use anything but Java, that's what the whole world is using", and here I am writing software in Haskell. Really, no troll intended. This is an open source world, I'll try my own Read and Show classes. If others like it, great, if not, I was wrong in the first place :) Best! Thanks for your attention, Maurício

As of today, show ((1,2)::(Float,Float)) would not produce that kind of output. Dan Piponi a écrit :
Mauricio asked:
Do you think 'read' (actually, 'readsPrec'?) could be made to also read the international convention (ie., read "1,5" would also work besides read "1.5")?
What would you hope the value of
read "(1,2,3)"::(Float,Float)
would be? -- Dan

Mauricio wrote:
Do you think 'read' (actually, 'readsPrec'?) could be made to also read the international convention
No. read and show are meant to be KISS, suitable for toy programs and casual debugging messages. Real applications should use or invent a sophisticated, general library. (The same way real user interfaces do not use getLine.)

Mauricio wrote:
Do you think 'read' (actually, 'readsPrec'?) could be made to also read the international convention (ie., read "1,5" would also work besides read "1.5")? I'm happy to finaly use a language where I can use words of my language to name variables, so I wonder if we could also make that step.
The purpose of 'read' is to read haskell notation, not to read locally-sensitive notation. So the right question to ask is "should we change haskell's lexical syntax to support locally-sensitive number notation". IMO, the answer is no. (1,3) would start to mean (13/10) and we'd need another notational rule (whitespace around commas) for numeric tuples. Feels like a painful special case to me. Jules

Do you think 'read' (actually, 'readsPrec'?) could be made to also read the international convention (ie., read "1,5" would also work besides read "1.5")? I'm happy to finaly use a language where I can use words of my language to name variables, so I wonder if we could also make that step.
The purpose of 'read' is to read haskell notation, not to read locally-sensitive notation.
So the right question to ask is "should we change haskell's lexical syntax to support locally-sensitive number notation".
IMO, the answer is no. (...)
Agree about the answer, not about the question. The correct one would be "is it possible to change haskell syntax to support the international notation (not any locally sensitive one) for decimal real numbers? Would a change in 'read' be a good first step?" I know this looks difficult, but I'm sure it deserves at least some thinking. We have previous examples for less important issues: ghc does accept Windows end of line conventions, the minus and sign needs special syntax, and '.' can be used as decimal separator even if it's use as function notation. Best, Maurício

Given examples like (1,2,3) I don't see how comma could ever be used
instead of dot, unless you insist on whitespace around all commas.
And that doesn't look like the right way forward.
-- Lennart
On Wed, Sep 17, 2008 at 4:20 PM, Mauricio
Do you think 'read' (actually, 'readsPrec'?) could be made to also read the international convention (ie., read "1,5" would also work besides read "1.5")? I'm happy to finaly use a language where I can use words of my language to name variables, so I wonder if we could also make that step.
The purpose of 'read' is to read haskell notation, not to read locally-sensitive notation.
So the right question to ask is "should we change haskell's lexical syntax to support locally-sensitive number notation".
IMO, the answer is no. (...)
Agree about the answer, not about the question. The correct one would be "is it possible to change haskell syntax to support the international notation (not any locally sensitive one) for decimal real numbers? Would a change in 'read' be a good first step?"
I know this looks difficult, but I'm sure it deserves at least some thinking. We have previous examples for less important issues: ghc does accept Windows end of line conventions, the minus and sign needs special syntax, and '.' can be used as decimal separator even if it's use as function notation.
Best, Maurício
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

On Tue, Sep 16, 2008 at 5:29 AM, Mauricio
Do you think 'read' (actually, 'readsPrec'?) could be made to also read the international convention (ie., read "1,5" would also work besides read "1.5")?
No, as read is really intended to be a language-level tool, not something that you should expose to end users. For locale-aware number input and formatting, you'd want to do something else.

Do you think 'read' (actually, 'readsPrec'?) could be made to also read the international convention (ie., read "1,5" would also work besides read "1.5")?
No, as read is really intended to be a language-level tool, not something that you should expose to end users. For locale-aware number input and formatting, you'd want to do something else.
Sure. What I think would be great if possible would be a language-level tool. The same way '.' can be used as decimal separator even if it's the function composition operator. If it's not possible to change the syntax, changing 'read' could be a good step (since, sometimes, 'read' is a good way to inialize some variables if proper care is taken. I know this sound weird, but it is an issue, for instance, when teaching programming. Students who face programming classes usually start writing numbers the wrong way, and sometimes this leads to confusion. A similar problem we had in the days when zeros were cut so they would be different of O, and now we have a lot of grown up people still writing 0 as if it were a greek phi. (As my father used to complain, when his students had to write something like phi=0.) Read and Show are, IMHO, a great way to initialize variables. a = read "123" is an alternative to a = 123, and maybe even a replacement. If, for instance, both show and read used some kind of delimiter, it would be easy to use reasonable ways to write constants of any kind. A big effort, but not less than is needed for unicode support in strings, and almost as usefull. Thanks, Maurício

On Tue, 16 Sep 2008, Mauricio wrote:
Hi,
A small annoyance some users outside english speaking countries usually experiment when learning programming languages is that real numbers use a '.' instead of ','. Of course, that is not such a problem except for the inconsistence between computer and free hand notation.
Read/Show is intended for parsing and formatting of Haskell expressions. Anything different should use different functions.
participants (13)
-
Aaron Denney
-
Albert Y. C. Lai
-
Brandon S. Allbery KF8NH
-
Bryan O'Sullivan
-
Dan Piponi
-
Henning Thielemann
-
Jules Bean
-
Lennart Augustsson
-
Mauricio
-
Miguel Mitrofanov
-
Rafael C. de Almeida
-
Tilo Wiklund
-
Twan van Laarhoven