From: Thomas 'PointedEars' Lahn on
Richard Cornford wrote:

> On Feb 17, 4:14 pm, Jorge wrote:
>> On Feb 17, 1:22 pm, Richard Cornford wrote:
>>> You may recall that Google Chrome had been observed to be
>>> getting this aspect of ES3 wrong (with regard to String
>>> object methods in those cases) long before there was an
>>> ES5 (or this change had been proposed), so for at least
>>> one of the participants in the ECMA committee getting the
>>> change passed meant not having to fix what had previously
>>> been a faulty script engine.
>>
>> Leaving aside compatibility with ES3, is there any benefit
>> in forcing "this" to be an object ?
>
> None.

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).


PointedEars
--
Use any version of Microsoft Frontpage to create your site.
(This won't prevent people from viewing your source, but no one
will want to steal it.)
-- from <http://www.vortex-webdesign.com/help/hidesource.htm> (404-comp.)
From: Peter Michaux on
On Feb 16, 3:23 pm, Jorge <jo...(a)jorgechamorro.com> wrote:
> Hi,
>
> Do you think -as I do- that the Math object is an ugly artifact ?

No.

Think of it as a namespace for Math functions.

> (2).pow(10)
> --> 1024

That is a perfect example of where message passing for (at least) Math
fails. The exponentiation function takes two arguments: base and
exponent. Neither is more important than the other. Neither is the
object to which I wish to send a message. Neither argument has state
that is or needs mutation. They are just arguments to a pure function
that has no side effects. Message passing is an inappropriate paradigm
for this sort of computation.

This looks a whole lot better:

pow(2, 10)

Adding a namespace is not significantly different:

Math.pow(2, 10)

Peter
From: Jorge on
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"
--
Jorge.
From: Jorge on
On Feb 17, 9:24 pm, Peter Michaux <petermich...(a)gmail.com> wrote:
> On Feb 16, 3:23 pm, Jorge <jo...(a)jorgechamorro.com> wrote:
>
> > Hi,
>
> > Do you think -as I do- that the Math object is an ugly artifact ?
>
> No.
>
> Think of it as a namespace for Math functions.
>
> > (2).pow(10)
> > --> 1024
>
> That is a perfect example of where message passing for (at least) Math
> fails. The exponentiation function takes two arguments: base and
> exponent. Neither is more important than the other. Neither is the
> object to which I wish to send a message. Neither argument has state
> that is or needs mutation. They are just arguments to a pure function
> that has no side effects. Message passing is an inappropriate paradigm
> for this sort of computation.
>
> This looks a whole lot better:
>
> pow(2, 10)
>
> Adding a namespace is not significantly different:
>
> Math.pow(2, 10)

I thought it was licit for an object's method to operate on the
object.
--
Jorge.
From: Thomas 'PointedEars' Lahn on
Peter Michaux wrote:

> Jorge wrote:
>> Do you think -as I do- that the Math object is an ugly artifact ?
>
> No.

ACK

> Think of it as a namespace for Math functions.

See below.

>> (2).pow(10)
>> --> 1024
>
> That is a perfect example of where message passing for (at least) Math
> fails.

What are you talking about? Nothing fails here.

> The exponentiation function takes two arguments: base and
> exponent. Neither is more important than the other.

Straw man.

> Neither is the object to which I wish to send a message.

Yes, the "object" is `2' (or `(2)').

> Neither argument has state that is or needs mutation.

Non sequitur. Messages do not need to cause mutation.

> They are just arguments to a pure function that has no side effects.

So what?

> Message passing is an inappropriate paradigm for this sort of
> computation.

Several designers of other languages, in particular Smalltalk, would
disagree.

> This looks a whole lot better:
>
> pow(2, 10)

Because it is prefix instead of infix style? Efficiency considerations
aside, that is is a matter of preference. And given that in math we are
writing

10
2

to display the value of "two to the tenth power", is it not more similar
and therefore more intuititive to write (2).pow(10) in source code? I know
at least one programming language that agrees here: bash (`$((2**10))').

> Adding a namespace is not significantly different:
>
> Math.pow(2, 10)

Non sequitur. No namespace is needed where the context is clear.


PointedEars
--
realism: HTML 4.01 Strict
evangelism: XHTML 1.0 Strict
madness: XHTML 1.1 as application/xhtml+xml
-- Bjoern Hoehrmann