[MLton] Re: [Sml-basis-discuss] Date.{from,to}String

Matthew Fluet fluet@cs.cornell.edu
Wed, 29 Dec 2004 11:56:32 -0500 (EST)


> I have another question regarding Date and string conversion.
>
> So what takes precendence, the equivalence to fmt/scan, or the fixed
> 24-character format?

MLton has recently begun thinking about adding WideChar (i.e., Unicode)
support, at the prompting of an interested contributer as well as from
other interested users.  This sparked some discussion about locale related
issues.  The (tentative) conclusion that we reached is that the Basis
Library mandated structures should stick to locale-independent operations.
In particular, the CHAR.is{Ascii,...,Upper} and CHAR.to{Lower,Upper}
functions are meant to be locale-indepdendent.  I would extend this to the
Date and Time functions, meaning that the 24-character format should take
precendence.

Since WideChar is matched by CHAR, the WideChar structure will need to
provide locale-independent instances of these functions; i.e., likely to
be constant true or false off of the ASCII set.  The is* and to* functions
are really locale dependent, so one reasonable option is to provide a
LOCALE signature that allows one to choose a locale and derive
locale-dependent functions.  The Date and Time (and I guess one could even
reasonably put Integer, Bool, etc.) {to,from}String and format functions
would appear to naturally fall into this structure.

signature LOCALE =
sig
  type t

  isAlpha : t * WideChar.char -> bool
  ...

  structure Date :
    sig
      val toString : t * Date.t -> WideString.string
      ...
    end

  ...
end

But, I'll repeat that these are only tentative design decisions.