From: Jorge on
On Feb 17, 10:08 pm, Jorge <jo...(a)jorgechamorro.com> wrote:
> On Feb 17, 9:24 pm, Peter Michaux <petermich...(a)gmail.com> wrote:
> (...)
> I thought it was licit for an object's method to operate on the
> object.

s/licit/legitimate/
--
Jorge.
From: Lasse Reichstein Nielsen on
Jorge <jorge(a)jorgechamorro.com> writes:

> On Feb 17, 9:21�pm, Thomas 'PointedEars' Lahn <PointedE...(a)web.de>
> wrote:
>>
>> Yes, there is: Repeated accesses to properties of `this' would not need
>> repeated conversion to object, whether inside the method context or outside
>> (if `this' was returned and the return value re-used).
>
> But these are just the specs. Implementations can optimize.
> IOW: "you can cheat if you don't get caught"

Indeed, it's quite possible to look up a property of Number.prototype
without creating a new Number object.

/L
--
Lasse Reichstein Holst Nielsen
'Javascript frameworks is a disruptive technology'

From: Jorge on
On Feb 17, 7:05 pm, Jorge <jo...(a)jorgechamorro.com> wrote:
>
> var x= 3;
> Number.prototype.test= function () { return this; };
> x.test() === x.test()
> --> false

@kangax: isn't this a nice one for the quiz ?
--
Jorge.
From: Jorge on
On Feb 17, 10:34 pm, Lasse Reichstein Nielsen <lrn.unr...(a)gmail.com>
wrote:
> Jorge <jo...(a)jorgechamorro.com> writes:
>
> > But these are just the specs. Implementations can optimize.
> > IOW: "you can cheat if you don't get caught"
>
> Indeed, it's quite possible to look up a property of Number.prototype
> without creating a new Number object.

Absolutely.
--
Jorge.
From: Thomas 'PointedEars' Lahn on
Lasse Reichstein Nielsen wrote:

> Jorge writes:
>> Thomas 'PointedEars' Lahn wrote:
>>> Yes, there is: Repeated accesses to properties of `this' would not need
>>> repeated conversion to object, whether inside the method context or
>>> outside (if `this' was returned and the return value re-used).
>>
>> But these are just the specs. Implementations can optimize.
>> IOW: "you can cheat if you don't get caught"

You would. Conforming implementations can only optimize where the
Specification does not forbid it.

> Indeed, it's quite possible to look up a property of Number.prototype
> without creating a new Number object.

Not in a conforming implementation of ECMAScript Edition 5. There is not
that much room to maneuver here:

| A conforming implementation of ECMAScript must provide and support all
| the types, values, objects, properties, functions, and program syntax
| and semantics described in this specification.
^^^^^^^^^^^^^


PointedEars
--
var bugRiddenCrashPronePieceOfJunk = (
navigator.userAgent.indexOf('MSIE 5') != -1
&& navigator.userAgent.indexOf('Mac') != -1
) // Plone, register_function.js:16