From: David Mark on
Gregor Kofler wrote:
> Am 2010-05-20 23:50, Andrea Giammarchi meinte:
>> new expression is basically an "elegant" module pattern recognizable
>> since the beginning.
>>
>> var o = (function () {}());
>>
>> what can "o" be? just everything, included undefined.
>
> Why "everything, including undefinded"? It's just gonna be undefined.
>

I don't know. I stopped reading after that. ;)
From: Richard Cornford on
On May 20, 10:50 pm, Andrea Giammarchi wrote:
> new expression is basically an "elegant" module pattern
> recognizable since the beginning.
>
> var o = (function () {}());
>
> what can "o" be? just everything, included undefined.

Might this not be a case of solving the wrong problem? Wouldn't it be
possible to chose an Identifier for use in place of 'o' that told the
reader of the code enough about the value that the variable was
expected to hold that they did not need to look any further unless
debugging showed evidence that the actual value was not consistent
with the expectation?

> var o = new function () {};
>
> what can "o" be in above case? Inevitably an object ;-)
<snip>

An object, but not necessarily the object that resulted from - new -
operation, and possibly a function, Date, RegExp, String, host, etc.
object. The use of the - new - operator really only grantees that the
value will not be a primitive, which isn't such a great step forward.

Richard.
From: Thomas 'PointedEars' Lahn on
David Mark wrote:

> Andrea Giammarchi wrote:
>> new expression is basically an "elegant" module pattern recognizable
>> since the beginning.
>>
>> var o = (function () {}());
>
> Good, except the last parenthesis is in the wrong spot.
^^^^^^^^^^
Opinions differ there.

>> var o = new function () {};
>>
>> what can "o" be in above case? Inevitably an object ;-)
>
> Too bad it is the wrong answer. :)

Pardon?

> Don't use that.

Not so at least. An implementation that does not support object
initializers could support anonymous function expressions; but it is
unlikely that it would not support the Object constructor/factory then.


PointedEars
--
Prototype.js was written by people who don't know javascript for people
who don't know javascript. People who don't know javascript are not
the best source of advice on designing systems that use javascript.
-- Richard Cornford, cljs, <f806at$ail$1$8300dec7(a)news.demon.co.uk>
From: Thomas 'PointedEars' Lahn on
Thomas 'PointedEars' Lahn wrote:

> David Mark wrote:
>> Andrea Giammarchi wrote:
>>> var o = new function () {};
>>>
>>> what can "o" be in above case? Inevitably an object ;-)
>>
>> Too bad it is the wrong answer. :)
>
> Pardon?

Ahh, did you mean the more specific "`o' must be the identifier of a
variable that has a reference to an object as its value"?


PointedEars
--
Danny Goodman's books are out of date and teach practices that are
positively harmful for cross-browser scripting.
-- Richard Cornford, cljs, <cife6q$253$1$8300dec7(a)news.demon.co.uk> (2004)
From: David Mark on
Thomas 'PointedEars' Lahn wrote:
> Thomas 'PointedEars' Lahn wrote:
>
>> David Mark wrote:
>>> Andrea Giammarchi wrote:
>>>> var o = new function () {};
>>>>
>>>> what can "o" be in above case? Inevitably an object ;-)
>>> Too bad it is the wrong answer. :)
>> Pardon?
>
> Ahh, did you mean the more specific "`o' must be the identifier of a
> variable that has a reference to an object as its value"?
>
>

No, my quoting obscured the fact that I was remarking on the pattern
choice. See follow-ups.