Possibility of standardized sprintf() in ES4?
denials at gmail.com
Sun Oct 28 16:39:08 PDT 2007
On 27/10/2007, Brendan Eich <brendan at mozilla.org> wrote:
> On Oct 27, 2007, at 11:06 AM, Dan Scott wrote:
> > Just following up on the discussion - since I've seen an
> > announcement that the spec for ES4 is now closed, does this mean
> > that a proposal for an addition of a standardized sprintf / format
> > addition to the String object is off the table until ES5? Or have
> > the Ecma members of the group decided that there is no actual
> > requirement for this functionality?
> See http://wiki.ecmascript.org/doku.php?
> id=discussion:string_formatting and also http://wiki.ecmascript.org/
> doku.php?id=meetings:minutes_feb_24_2006&s=string+formatting, which
> # String formatting choices:
> * Leave out, defer to the emergent standard library ecology?
> Then lose type system tie-in opportunites.
> * .NET vs. MSCOM vs. Java vs. others leaves no single obvious
> choice of what to imitate.
> * OCaml, other precedents? Roll-our-own function-combinatorial
> typed formatting? Too inconvenient.
> * Ed points out that strings imply localization, more worms.
> These considerations suggested to us that we defer this to the
> library ecosystem. But we could have missed an opportunity here.
Ah, fabulous - it seems that although the term "sprintf" appears in the
wiki, it's highlighted and therefore doesn't turn up in a search for the
term. And I was too dumb to search for "string format" -- thanks for letting
me know that the issue had been raised in the past and that there had been
some discussion about it.
> Beyond raising this issue on the mailing list and finding some
> > support in principle for the proposal, if not for the actual form
> > of the proposal, I'm not sure what the next step is supposed to be.
> > It does seem like a major functionality gap in the language, to me,
> > but I'm only one small voice.
> In your view, is it a gap in the standard library, a gap to fill by
> competing libraries before anything is standardized, or truly a gap
> in the core language? For there to be a gap in the core language, it
> seems to me the proposal must involve static type checking of actual
> arguments against format specifiers. Otherwise, as Lars noted in the
> discussion page, even ES3 has enough reflection to build a
> dynamically type-safe formatter as library code. Successful Ajax
> libraries have built such things.
I n my view, it's simply a gap in the standard library (and I apologize if
this was not the correct forum to raise concerns about the standard library
vs. the core language spec). As I noted at the outset, there are a wide
variety of sprintf() (and probably String.format()) implementations already
out in the wild under various licenses and with varying sophistication. I
believe that adding such a method to the standard library would help
simplify the current situation and increase the ease of reusing code between
Thanks for taking the time to respond, Brendan - I really appreciate it, as
well as the rest of your efforts to bring ES4 to fruition.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Es4-discuss