H98 Text IO

Iavor Diatchki iavor.diatchki at gmail.com
Wed Feb 27 16:20:35 EST 2008


Hi,
My preference would be for handles to have a "mode" that specifies the
encoding to use when reading and writing characters.  By default, the
mode should be set to the encoding specified in the locale but we
should also provide an explicit "setEncoding" method so that
programmers can specify the encoding to be used explicitly.
-Iavor


On Wed, Feb 27, 2008 at 12:19 PM, David Roundy <droundy at darcs.net> wrote:
> On Wed, Feb 27, 2008 at 06:05:46PM +0100, Thorkil Naur wrote:
>  > Hello,
>  >
>  > 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
>  > appropriate.
>  >
>  > 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.
>
> --
>  David Roundy
>  Department of Physics
>  Oregon State University
>  _______________________________________________
>
>
> Libraries mailing list
>  Libraries at haskell.org
>  http://www.haskell.org/mailman/listinfo/libraries
>


More information about the Libraries mailing list