ES3.1 Draft: String generics
Douglas Crockford
douglas at crockford.com
Wed May 7 05:23:03 PDT 2008
We should nail down the meaning of /\s/. Should it be the minimum (IE) or the
maximum (Opera)?
Pratap Lakshman (VJ#SDK) wrote:
> I have uploaded to the wiki a draft proposal
> <http://wiki.ecmascript.org/lib/exe/fetch.php?id=es3.1%3Atargeted_additions_to_array_string_object_date&cache=cache&media=es3.1:es31_stringobject.pdf>
> to add a couple of generics to the String object. In order to retain the
> subset relationship with proposed ES4, these should be considered for
> addition to ES4 too.
>
>
>
> I have extracted the String portion of the ES3 spec, added a rationale
> (with hyperlinks) at the beginning, and made relevant changes to the
> included section 15.5 text, with some comments added. I have tried to be
> mindful of compat.
>
>
>
> pratap
>
>
>
>
>
> *From:* Brendan Eich [mailto:brendan at mozilla.com]
> *Sent:* Thursday, May 01, 2008 5:21 AM
> *To:* Pratap Lakshman (VJ#SDK)
> *Cc:* es3.x-discuss at mozilla.org
> *Subject:* Re: Static generics on String
>
>
>
> On Apr 30, 2008, at 8:58 AM, Pratap Lakshman (VJ#SDK) wrote:
>
> Yes, I did notice that these are already on String.prototype, and
> that they are generic. Is proposed-ES4 going to add a static method
> of the same name for each such prototype generic method?!
>
>
>
> Yes.
>
>
>
> The ES3 String.prototype methods generally specify that ToString is
> applied to "this" and to string arguments. Is it also the case for the
> String generics? If so, it would seen to limit their utility for string
> like wrappers or alternative string representations?
>
>
>
> The ToString is ok if you are willing to tolerate the overhead of a
> copy. Alternative is to do length and indexed accesses to the wrapper,
> which forwards to the java.lang.String or similar. But that changes how
> ES1-3 are spec'ed and it's work -- and premature optimization is the
> root of all evil.
>
>
>
> Is your experience that the static generic string methods have “carried
> their weight” in your implementations. In other words, based upon your
> experience would you recommend their inclusion in ES3.1?
>
>
>
> Not for 3.1. They are cheap to implement but 3.1 has enough to do, and
> the String static generics are not big-bang-for-the-buck.
>
>
>
> Is there a general rule for where we (proposed-ES4 & ES3.1) should add
> any new generic methods? In ES3.1 we are considering adding a "trim" and
> a "quote" method for Strings, and I was thinking of adding these on
> String.prototype (just like the other generic methods). However, the
> static generics proposal page suggests that they should then also be
> added as statics on String.
>
>
>
> If you skip adding any static generics for 3.1, no worries.
>
>
>
> Can you say more about quote? We've implemented it for years. Need to
> get it into both 3.1 and 4 to keep the subset relation.
>
>
>
> To conform to the rest of the ES3, I shall propose adding these methods
> (trim and quote) to String.prototype only, and not create a parallel set
> of statics.
>
> Do you see any issues with this proposal?
>
> No, that sounds good. Let's just get quote on the ES4 radar. Is there a
> spec for it?
>
>
>
> /be
>
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> Es3.x-discuss mailing list
> Es3.x-discuss at mozilla.org
> https://mail.mozilla.org/listinfo/es3.x-discuss
More information about the Es4-discuss
mailing list