H98 Text IO
droundy at darcs.net
Wed Feb 27 15:19:18 EST 2008
On Wed, Feb 27, 2008 at 06:05:46PM +0100, Thorkil Naur wrote:
> On Wednesday 27 February 2008 17:30, Ian Lynagh wrote:
> > On Tue, Feb 26, 2008 at 07:30:08PM -0500, David Roundy wrote:
> > > On Wed, Feb 27, 2008 at 12:06:59AM +0000, Duncan Coutts wrote:
> > > > I think personally I'm coming round to the "always locale" point of
> > > > view. We already have no cross-platform consistency for text files
> > > > because of the lf vs cr/lf issue and we have no cross-implementation
> > > > consistency.
> > >
> > > I'm leaning in the same direction.
> > This has swung me too.
> Let me be contrary, then: The "always locale" idea depends, as I understand
> it, on some relatively global setting. And, especially in the context of
> functional programming, global things dont strike me as particularly
> This particular global thing also has the wonderful property of being
> modifiable. So it is actually a global variable.Some years ago, I had a hard
> time because some program that I hadn't written, but had to call from my
> program, occasionally changed the locale setting when called. The problem
> turned out, after much and exasperating work, to be that this changed the
> behaviour of sprintf: In Denmark we use commas for decimal points.
Of course, something like sprintf would be a pure function (and thus safe,
but also perhaps incorrect) in Haskell...
It'd be up to the implementors whether to indeed allow the locale setting
to be modified during the course of a program running, there's certainly no
requirement that it be mutable, and certainly it need not be externally
mutable. If we only check the locale once, we're safe from all "locale
rotating with the phase of the moon" bugs. Certainly stdin/out/err would
be safe, because they'd only be opened when the program starts.
Department of Physics
Oregon State University
More information about the Libraries