Removing String, Number and Boolean

Mark S. Miller erights at google.com
Sun May 9 15:14:41 PDT 2010


On Sun, May 9, 2010 at 3:08 PM, Mike Samuel <mikesamuel at gmail.com> wrote:

> 2010/5/9 Mark S. Miller <erights at google.com>:
> > On Sun, May 9, 2010 at 2:41 PM, Erik Arvidsson <erik.arvidsson at gmail.com
> >
> > wrote:
> >>
> >> We have previously discussed removing the object wrappers of string,
> >> number and boolean, referred to as String, Number and Boolean. It is
> >> too bad we forgot about these when we introduced strict mode in ES5. I
> >> hope we can remove them from Harmony?
> >
> > We didn't forget. (In fact, we spent a long time working this out.)
> > ES5/strict removes these wrappers as much as it can given the
> constraints.
> > Remember that strict vs non-strict is per code, not per heap. Strict and
> > non-strict code must co-exist in the same heap with access to the same
> > objects. Thus, we can't actually remove the wrappers without breaking
> > compatibility. What ES5/strict did instead is to remove from strict code
> the
> > case that causes implicit wrapping -- the coercion of "this" to an
> object.
> > An example is at
> > <
> http://google-caja.googlecode.com/svn/trunk/doc/html/es5-talk/img38.html>.
> > As shown by this example, the net effect is that booleans still act like
> > they inherit from Boolean.prototype, but without the wrapping confusion.
> > Likewise of course for all primitive types.
>


> > Together, if a whole program
> > * only contains strict code
> > * never explicitly calls a wrapper constructor
>
> * never explicitly calls Object(...)
>

Yes. Good catch.


> * never attaches a non-strict method to a wrapper or Object prototype
> that returns this


The existence for a non-strict method anywhere within the whole program
violates my first condition.


> > then it should never encounter any wrappers.
> >
> >>
> >> --
> >> erik
> >> _______________________________________________
> >> es-discuss mailing list
> >> es-discuss at mozilla.org
> >> https://mail.mozilla.org/listinfo/es-discuss
> >
> >
> >
> > --
> >     Cheers,
> >     --MarkM
> >
> > _______________________________________________
> > es-discuss mailing list
> > es-discuss at mozilla.org
> > https://mail.mozilla.org/listinfo/es-discuss
> >
> >
>



-- 
    Cheers,
    --MarkM
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20100509/c8b9e7a5/attachment-0001.html>


More information about the es-discuss mailing list