Re: std.locale

2009-03-04 Thread Georg Wrede
Sean Kelly wrote: == Quote from Walter Bright (newshou...@digitalmars.com)'s article Andrei Alexandrescu wrote: I agree. I'm having the same problem: I put a contract in there, I know it's as good as assert. So I can't do e.g. input validation because in most functions input must always be

Re: std.locale

2009-03-04 Thread Derek Parnell
On Wed, 04 Mar 2009 08:12:48 -0800, Sean Kelly wrote: So I guess the real question is whether a function is expected to validate its parameters. I'd argue that it isn't, but then I'm from a C/C++ background. For me, validation is a debugging tool, or at least an optional feature for

Re: std.locale

2009-03-04 Thread Walter Bright
Sean Kelly wrote: Why should contracts be limited to parameter checking of internally used functions only? If I write a function and document parameter constraints then I certainly expect those constraints to be followed regardless of whether I'm calling the function or someone else is calling

Re: std.locale

2009-03-03 Thread Michel Fortin
On 2009-03-02 23:27:49 -0500, Andrei Alexandrescu seewebsiteforem...@erdani.org said: Georg Wrede wrote: [snip] Well I guess what I'll do is take the path of least resistance - nothing. Looks like locales are rather unpopular... Sad. Seriously, I think if D could have locales as a

Re: std.locale

2009-03-03 Thread Gide Nwawudu
On Mon, 02 Mar 2009 01:37:55 -0800, Walter Bright newshou...@digitalmars.com wrote: Georg Wrede wrote: We've had Walter make nice features to D that were laborious to create, only to see nobody use them. It's happened, ask him. Sure. Often the only way to see if a feature is useful is to

Re: std.locale

2009-03-03 Thread Daniel Keep
Walter Bright wrote: Georg Wrede wrote: We've had Walter make nice features to D that were laborious to create, only to see nobody use them. It's happened, ask him. Sure. Often the only way to see if a feature is useful is to actually implement it and see what happens. Some features have

Re: std.locale

2009-03-03 Thread bearophile
Daniel Keep: So I put contracts on everything. Fantastic. I do a release compile, and all that safety disappears. So only the debug build has contracts enabled. But it's the release build, if it crashes, that I need help diagnosing. A simple solution is to not use -release for the final

Re: std.locale

2009-03-03 Thread Andrei Alexandrescu
bearophile wrote: Daniel Keep: So I put contracts on everything. Fantastic. I do a release compile, and all that safety disappears. So only the debug build has contracts enabled. But it's the release build, if it crashes, that I need help diagnosing. A simple solution is to not use

Re: std.locale

2009-03-03 Thread Sergey Gromov
Tue, 03 Mar 2009 07:05:51 -0800, Andrei Alexandrescu wrote: bearophile wrote: Daniel Keep: So I put contracts on everything. Fantastic. I do a release compile, and all that safety disappears. So only the debug build has contracts enabled. But it's the release build, if it crashes, that I

Re: std.locale

2009-03-03 Thread Sean Kelly
Michel Fortin wrote: On 2009-03-02 14:58:26 -0500, Walter Bright newshou...@digitalmars.com said: It's a silly thing, but I love the little google widget you can add to a web page to automatically translate the pages. All the D site pages have it in the left column. It's not a silly thing,

Re: std.locale

2009-03-03 Thread Walter Bright
Andrei Alexandrescu wrote: I agree. I'm having the same problem: I put a contract in there, I know it's as good as assert. So I can't do e.g. input validation because in most functions input must always be validated. I also know that contracts are doing the wrong thing with inheritance and

Re: std.locale

2009-03-03 Thread Max Samukha
On Tue, 03 Mar 2009 11:00:36 -0800, Walter Bright newshou...@digitalmars.com wrote: Andrei Alexandrescu wrote: I agree. I'm having the same problem: I put a contract in there, I know it's as good as assert. So I can't do e.g. input validation because in most functions input must always be

Re: std.locale

2009-03-03 Thread Sean Kelly
== Quote from Walter Bright (newshou...@digitalmars.com)'s article Andrei Alexandrescu wrote: I agree. I'm having the same problem: I put a contract in there, I know it's as good as assert. So I can't do e.g. input validation because in most functions input must always be validated. I also

Re: std.locale

2009-03-03 Thread Derek Parnell
On Tue, 03 Mar 2009 11:00:36 -0800, Walter Bright wrote: Contracts are not for input validation! Hear! Hear! This is exactly correct. -- Derek Parnell Melbourne, Australia skype: derek.j.parnell

Re: std.locale

2009-03-02 Thread Rainer Deyke
Georg Wrede wrote: Let's split this into two separate issues, the console and the GUI. The GUI is aware of your preferences. You don't use writefln with the GUI. You use the GUI API for any I/O, right? There's a third faction: graphical apps that don't use the underlying GUI API. Most

Re: std.locale

2009-03-02 Thread Don
Georg Wrede wrote: Walter Bright wrote: Andrei Alexandrescu wrote: There will be a global reference to a Locale class, e.g. defaultLocale. By default the reference will be null, implying the C locale should be in effect. Applications can assign to it as they find fit, and also pass around

Re: std.locale

2009-03-02 Thread Georg Wrede
Andrei Alexandrescu wrote: Georg Wrede wrote: Andrei Alexandrescu wrote: Sooner or later that will need to be defined. I know next to nothing about locales. (I know I dislike the design C++ uses.) D uses Utf-8, and that is *good enough*! This lets my programs understand Finnish, and doesn't

Re: std.locale

2009-03-02 Thread Georg Wrede
Walter Bright wrote: Georg Wrede wrote: We've had Walter make nice features to D that were laborious to create, only to see nobody use them. It's happened, ask him. Sure. Often the only way to see if a feature is useful is to actually implement it and see what happens. Some features have

Re: std.locale

2009-03-02 Thread Christopher Wright
Georg Wrede wrote: (You know, a few years ago we had a major conversation here about whether non-ASCII variable names should be accepted in D. The end result is, yes. (I just tried it.) Now, how can an international team cowork on a project where variable names are written so the other folks

Re: std.locale

2009-03-02 Thread Christopher Wright
Georg Wrede wrote: The hypothetical Ambitious Programmer might want to use locale. He could then have the dates and times (and currencies, etc.) follow the country. Now, that might sound commendable, but in practice it *crumbles*. He can't possibly know how to deal with languages that are

Re: std.locale

2009-03-02 Thread Michel Fortin
is a concept too abstract to be able to do something good with it. Since you could only define it using Algebraic type and a loosely defined tree of strings, that seems to confirm my view. Call the module std.locale if you want, but keep in mind that the most important task at hand is facilitating

Re: std.locale

2009-03-02 Thread Frits van Bommel
Don wrote: there's no simple solution. (gripe They could at least recognize that outside the US, everyone uses A4-size paper, not that bizarro letter/legal stuff /gripe). Amen! It is usual that the user needs to write, say, in Swedish or in Russian, while in a Finnish setting. Or that one

Re: std.locale

2009-03-02 Thread Leandro Lucarella
Andrei Alexandrescu, el 1 de marzo a las 19:40 me escribiste: Georg Wrede wrote: Andrei Alexandrescu wrote: Sooner or later that will need to be defined. I know next to nothing about locales. (I know I dislike the design C++ uses.) D uses Utf-8, and that is *good enough*! This lets my

Re: std.locale

2009-03-02 Thread grauzone
What is language specific about how an array is formatted? I think you're abusing the locale stuff as some kind of user customization mechanism for format().

Re: std.locale

2009-03-02 Thread Leandro Lucarella
Michel Fortin, el 2 de marzo a las 07:30 me escribiste: On 2009-03-02 01:04:47 -0500, Andrei Alexandrescu seewebsiteforem...@erdani.org said: Good idea. But before we do so, I was hoping I'd pick the brains of people who have used locales in other languages and understand the burning

Re: std.locale

2009-03-02 Thread Andrei Alexandrescu
Georg Wrede wrote: Andrei Alexandrescu wrote: An excellent string hierarchy without the entire rest of i18n, is only going to look like a Ferrari with a Trabant engine. Which is worse than nothing at all. I don't understand this. What is the rest of i18n? i18n stands for

Re: std.locale

2009-03-02 Thread Andrei Alexandrescu
Michel Fortin wrote: On 2009-03-02 08:32:40 -0500, Leandro Lucarella llu...@gmail.com said: I'm not following this thread carefully and I don't know if this is what you are implying, but: Please don't you even think in duplicating the locale stuff, at least on unix there is a very nice

Re: std.locale

2009-03-02 Thread Daniel Keep
Andrei Alexandrescu wrote: Georg Wrede wrote: *** How to print arrays *** You print arrays in a predictable and expected way. D array printing is for non-GUI stuff. Hence, you use the C locale, period. I think the C locale (or any predefined locale) tells what left bracket I should

Re: std.locale

2009-03-02 Thread Sergey Gromov
Mon, 02 Mar 2009 09:34:32 +0200, Georg Wrede wrote: Of course, eventually we will want to do something about this. But that should be left to the day when real issues are all sorted out in D. This is a non-urgent, low-priority thing. Had there been any need for locales, believe me, the

Re: std.locale

2009-03-02 Thread Andrei Alexandrescu
. Well I was thinking of passing the buck around. Instead of std.locale defining a hierarchy for formatting numbers and dates, it provides a means for user code to plant a routine in the locale object that knows how to format numbers and dates. Of course, with time default localized routine

Re: std.locale

2009-03-02 Thread Andrei Alexandrescu
Sergey Gromov wrote: Mon, 02 Mar 2009 09:34:32 +0200, Georg Wrede wrote: Of course, eventually we will want to do something about this. But that should be left to the day when real issues are all sorted out in D. This is a non-urgent, low-priority thing. Had there been any need for locales,

Re: std.locale

2009-03-02 Thread Sergey Gromov
Mon, 02 Mar 2009 07:02:10 -0800, Andrei Alexandrescu wrote: Consider some code in phobos that must throw an exception: throw Exception(File `%s' not found, system error is %s., filename, errnomsg); The localized version will look like this: auto format = File `%s' not found,

Re: std.locale

2009-03-02 Thread Georg Wrede
Andrei Alexandrescu wrote: Georg Wrede wrote: You see, we're not communicating. I sent this link: http://www.unicode.org/cldr/ Did you look at it? It is essentially a database of locale information in a highly structured format. All I want is to define a structure expressive enough to gobble

Re: std.locale

2009-03-02 Thread Andrei Alexandrescu
Georg Wrede wrote: Andrei Alexandrescu wrote: Georg Wrede wrote: You see, we're not communicating. I sent this link: http://www.unicode.org/cldr/ Did you look at it? It is essentially a database of locale information in a highly structured format. All I want is to define a structure

Re: std.locale

2009-03-02 Thread Andrei Alexandrescu
Sergey Gromov wrote: Mon, 02 Mar 2009 07:02:10 -0800, Andrei Alexandrescu wrote: Consider some code in phobos that must throw an exception: throw Exception(File `%s' not found, system error is %s., filename, errnomsg); The localized version will look like this: auto format = File `%s'

Re: std.locale

2009-03-02 Thread Walter Bright
Christopher Wright wrote: -- All very nice, but no cigar. That's about as smart as letting people define *unlimited* length variable names!) I recently dealt with a programming language that specified a limit of 63 characters for identifier names. This wouldn't have been a significant

Re: std.locale

2009-03-02 Thread Yigal Chripun
Sergey Gromov wrote: Mon, 02 Mar 2009 09:34:32 +0200, Georg Wrede wrote: Of course, eventually we will want to do something about this. But that should be left to the day when real issues are all sorted out in D. This is a non-urgent, low-priority thing. Had there been any need for locales,

Re: std.locale

2009-03-02 Thread Rainer Deyke
Sergey Gromov wrote: To actually solve this problem the default exception handler must be fixed to convert any UTF-8 into the current OEM code page before printing. It would also help if default stdin and stdout performed such a conversion. No, stdin/stdout *must* perform this conversion.

Re: std.locale

2009-03-02 Thread Jarrett Billingsley
On Mon, Mar 2, 2009 at 1:52 PM, Georg Wrede georg.wr...@iki.fi wrote: My take:  * This is still a moving target  * Using this is a major hassle for the programmer  * With D2 itelf a moving target, nobody is going to invest enough time in this to actually use it for something worthwhile in

Re: std.locale

2009-03-02 Thread Walter Bright
Jarrett Billingsley wrote: functions for indexing and slicing on character boundaries) before this. These already exist in std.uni.

Re: std.locale

2009-03-02 Thread Andrei Alexandrescu
Rainer Deyke wrote: Sergey Gromov wrote: To actually solve this problem the default exception handler must be fixed to convert any UTF-8 into the current OEM code page before printing. It would also help if default stdin and stdout performed such a conversion. No, stdin/stdout *must* perform

Re: std.locale

2009-03-02 Thread Daniel Keep
Andrei Alexandrescu wrote: Rainer Deyke wrote: Sergey Gromov wrote: To actually solve this problem the default exception handler must be fixed to convert any UTF-8 into the current OEM code page before printing. It would also help if default stdin and stdout performed such a conversion.

Re: std.locale

2009-03-02 Thread Andrei Alexandrescu
Daniel Keep wrote: Andrei Alexandrescu wrote: Rainer Deyke wrote: Sergey Gromov wrote: To actually solve this problem the default exception handler must be fixed to convert any UTF-8 into the current OEM code page before printing. It would also help if default stdin and stdout performed

Re: std.locale

2009-03-02 Thread Sergey Gromov
Mon, 02 Mar 2009 12:53:48 -0800, Andrei Alexandrescu wrote: Rainer Deyke wrote: Sergey Gromov wrote: To actually solve this problem the default exception handler must be fixed to convert any UTF-8 into the current OEM code page before printing. It would also help if default stdin and stdout

Re: std.locale

2009-03-02 Thread Christopher Wright
Andrei Alexandrescu wrote: If you want to provide a specific date formatter, you plant a delegate in the locale table. The code in Phobos doing formatting will detect that and call your delegate passing in the date. You do whatever you want on your side (format on the spot, use your own class

Re: std.locale

2009-03-02 Thread Andrei Alexandrescu
Christopher Wright wrote: Andrei Alexandrescu wrote: If you want to provide a specific date formatter, you plant a delegate in the locale table. The code in Phobos doing formatting will detect that and call your delegate passing in the date. You do whatever you want on your side (format on

Re: std.locale

2009-03-02 Thread Christopher Wright
Andrei Alexandrescu wrote: The localized version will look like this: auto format = File `%s' not found, system error is %s.; auto localFormat = currentLocale ? currentLocale.peek(format) : null; if (!localFormat) localFormat = format; throw Exception(localFormat, filename, errnomsg); This

Re: std.locale

2009-03-02 Thread Derek Parnell
On Mon, 02 Mar 2009 06:28:12 -0800, Andrei Alexandrescu wrote: You're right, we won't engage in the business of maintaining locale databases. We provide mechanism, not policy. Ok, for awhile there I thought you were attempting to duplicate the efforts that the operating systems already do.

Re: std.locale

2009-03-02 Thread Michel Fortin
On 2009-03-02 14:58:26 -0500, Walter Bright newshou...@digitalmars.com said: It's a silly thing, but I love the little google widget you can add to a web page to automatically translate the pages. All the D site pages have it in the left column. It's not a silly thing, it's hilarious. Look,

Re: std.locale

2009-03-02 Thread Walter Bright
Michel Fortin wrote: On 2009-03-02 14:58:26 -0500, Walter Bright newshou...@digitalmars.com said: It's a silly thing, but I love the little google widget you can add to a web page to automatically translate the pages. All the D site pages have it in the left column. It's not a silly thing,

Re: std.locale

2009-03-02 Thread Derek Parnell
On Mon, 02 Mar 2009 18:36:09 -0800, Andrei Alexandrescu wrote: Phobos has supported Posix positional syntax since 2.006. http://digitalmars.com/d/2.0/phobos/std_stdio.html Thank you. I was behind the times (again). -- Derek Parnell Melbourne, Australia skype: derek.j.parnell

Re: std.locale

2009-03-02 Thread Michel Fortin
for instance: you have a base class to format dates, another for numbers; you can easily create your own subclass if you want, and there's a way to get the default formatter instance. Well I was thinking of passing the buck around. Instead of std.locale defining a hierarchy for formatting numbers

Re: std.locale

2009-03-02 Thread Georg Wrede
Andrei Alexandrescu wrote: In another post you sounded as if there is a connection between this stuff and printing arrays. I'm not sure I see the connection. Very simple. If we have a locale table, I am thinking of dedicating a branch std in it to stuff that's in std. For example, I can use

std.locale

2009-03-01 Thread Andrei Alexandrescu
Sooner or later that will need to be defined. I know next to nothing about locales. (I know I dislike the design C++ uses.) I was thinking of a design along the following lines. There are RFCs dedicated to locale nomenclature: http://tools.ietf.org/html/rfc4646 for language names

Re: std.locale

2009-03-01 Thread Walter Bright
Andrei Alexandrescu wrote: There will be a global reference to a Locale class, e.g. defaultLocale. By default the reference will be null, implying the C locale should be in effect. Applications can assign to it as they find fit, and also pass around multiple locale variables. I disagree with

Re: std.locale

2009-03-01 Thread Georg Wrede
Andrei Alexandrescu wrote: Sooner or later that will need to be defined. I know next to nothing about locales. (I know I dislike the design C++ uses.) D uses Utf-8, and that is *good enough*! This lets my programs understand Finnish, and doesn't give me undue headaches. Seriously tending

Re: std.locale

2009-03-01 Thread Andrei Alexandrescu
Walter Bright wrote: Andrei Alexandrescu wrote: There will be a global reference to a Locale class, e.g. defaultLocale. By default the reference will be null, implying the C locale should be in effect. Applications can assign to it as they find fit, and also pass around multiple locale

Re: std.locale

2009-03-01 Thread Andrei Alexandrescu
Georg Wrede wrote: Andrei Alexandrescu wrote: Sooner or later that will need to be defined. I know next to nothing about locales. (I know I dislike the design C++ uses.) D uses Utf-8, and that is *good enough*! This lets my programs understand Finnish, and doesn't give me undue headaches.

Re: std.locale

2009-03-01 Thread Georg Wrede
Walter Bright wrote: Andrei Alexandrescu wrote: There will be a global reference to a Locale class, e.g. defaultLocale. By default the reference will be null, implying the C locale should be in effect. Applications can assign to it as they find fit, and also pass around multiple locale

Re: std.locale

2009-03-01 Thread Andrei Alexandrescu
Georg Wrede wrote: Walter Bright wrote: Andrei Alexandrescu wrote: There will be a global reference to a Locale class, e.g. defaultLocale. By default the reference will be null, implying the C locale should be in effect. Applications can assign to it as they find fit, and also pass around

Re: std.locale

2009-03-01 Thread Walter Bright
Andrei Alexandrescu wrote: Walter Bright wrote: Andrei Alexandrescu wrote: There will be a global reference to a Locale class, e.g. defaultLocale. By default the reference will be null, implying the C locale should be in effect. Applications can assign to it as they find fit, and also pass

Re: std.locale

2009-03-01 Thread Walter Bright
Georg Wrede wrote: What else? Well, it is conceivable that he wants his program to print dates and times the way it's done over there. He simply writes the program by hand so it does dates and times like he wants. Even if there was a locale thing in the language, he wouldn't bother with the

Re: std.locale

2009-03-01 Thread Andrei Alexandrescu
Walter Bright wrote: Andrei Alexandrescu wrote: Walter Bright wrote: Andrei Alexandrescu wrote: There will be a global reference to a Locale class, e.g. defaultLocale. By default the reference will be null, implying the C locale should be in effect. Applications can assign to it as they

Re: std.locale

2009-03-01 Thread Joel C. Salomon
Walter Bright wrote: I've attempted to use locales, but the reason I'd always wind up doing it by hand is because the existing libraries to do it are obtuse, impenetrable, execrable, and pretty much unusable. So it may be that it's an insoluble problem, or maybe nobody has come up with the

Re: std.locale

2009-03-01 Thread Ellery Newcomer
Georg Wrede wrote: Andrei Alexandrescu wrote: Sooner or later that will need to be defined. I know next to nothing about locales. (I know I dislike the design C++ uses.) D uses Utf-8, and that is *good enough*! This lets my programs understand Finnish, and doesn't give me undue headaches.

Re: std.locale

2009-03-01 Thread Andrei Alexandrescu
Walter Bright wrote: Andrei Alexandrescu wrote: Well I was thinking a global reference might be handy for people who e.g. want to set the locale once and then be done with it. That's what I was objecting to! I think only a few apps actually manipulate multiple locales simultaneously. Most

Re: std.locale

2009-03-01 Thread Andrei Alexandrescu
Joel C. Salomon wrote: Walter Bright wrote: I've attempted to use locales, but the reason I'd always wind up doing it by hand is because the existing libraries to do it are obtuse, impenetrable, execrable, and pretty much unusable. So it may be that it's an insoluble problem, or maybe nobody

Re: std.locale

2009-03-01 Thread Georg Wrede
Andrei Alexandrescu wrote: Georg Wrede wrote: Walter Bright wrote: Andrei Alexandrescu wrote: There will be a global reference to a Locale class, e.g. defaultLocale. By default the reference will be null, implying the C locale should be in effect. Applications can assign to it as they find