From: Garrett Smith on
Thomas 'PointedEars' Lahn wrote:
> Garrett Smith wrote:
>
>> Thomas 'PointedEars' Lahn wrote:
>>> Garrett Smith wrote:
>>>> Scott Sauyet wrote:
>>>>> On Jan 25, 3:50 pm, Asen Bozhilov <asen.bozhi...(a)gmail.com> wrote:
>>>>>> I want Singleton with properties:
>>>>>> - Doesn't have constructor

I take it he wants a Singleton without a constructor property. Did I get
that wrong?

>>>> Why not?
>>> The question is pointless; it simply cannot be done. Every object
>>> has a constructor, even those created with initializers.
>> Not every object will have constructor.
>
> True.
>
>> Even if changed to "Every native object", it would still not be true.
>
> True, the Global Object makes an exception there. There is no description
> in the Specification how it is created; it is simply "created before
> control enters any execution context" and then it "is there".
>
>> Even if changed to "Every object except the global object," it would
>> still not be true.
>
> Yes, it would. While maybe not accessible from ECMAScript code, host
> objects need to have a constructor somewhere by which they have been
> constructed.
>

A host object is not required to have a constructor; not at least as far
as a program is concerned.

I did interpret Asen's meaning of "I want Singleton with properties: -
Doesn't have constructor" to mean that the object would not have a
constructor property.

I can't think of any reason why he would be making program requirements
about unobservable implementation details.

It sounds like you are interpreting the word "constructor" in general
sense, to mean the thing that was new'd, and then further broadening
that to include the implementation details of the Host. That seems to be
broadening context of the discussion.

That is not what I interpreted. I read Asen's message as meaning
"constructor" property, and as something observable by ECMAScript.

An ECMAScript engine's implementation language is not something that the
ECMA-262 gets to decide upon. That language is not required to have
constructors, and so although the implementation most likely does (C,
C++, Java), it is neither required nor observable.

>> A new'd object automatically gets a [[Prototype]] from the object that
>> constructed it. The constructor comes from that.
>
> No, the constructor needs to exist before.
>

My sentence is referring to the `constructor` property. The examples I
posted follow that.

Now if by "constructor" you mean not constructor property, but the
(function) object that implements [[Construct]].

If we are talking about Object, it might be the case that Object is not
present. There is some sort of primordial preservation in
implementations. I am using the term "primordial" to describe what is
built-in, but internally preserved. I got this term from reading
es-discuss subject "Module isolation".

(function(){
Object = null;
return ({}).constructor;
})();

Results null;

The obvious observation, however, is that object *was* created, and so
it may seem odd that the object's constructor property points to global
Object, which is null, yet the the object is created "as if by the
expression `new Object`.

As a bookmarklet:

javascript: alert( function(){Object = null;return ({ ctor :
Object}).ctor;}() )

elerts "null"

The result shows that the object is created. This happens "as if by the
expression `new Object()`". The object literal has a constructor
property that points to Object, which is null (AISB).

>> The global object's [[Prototype]] is implementation dependent, so it
>> might have any [[constructor. [...]
>
> I was not talking about the `constructor' property. You miss the point.
>

Did I? I thought the point was to create a Singleton without a
constructor property. Asen - what was your meaning?
--
Garrett
comp.lang.javascript FAQ: http://jibbering.com/faq/
From: Asen Bozhilov on
Garrett Smith wrote:

> Did I? I thought the point was to create a Singleton without a
> constructor property. Asen - what was your meaning?

I mean:

- Doesn't have [[Construct]] method and `Singleton` cannot be use as
part of `new Singleton()` expression.
From: Scott Sauyet on
On Jan 27, 9:59 am, Asen Bozhilov <asen.bozhi...(a)gmail.com> wrote:
> Garrett Smith wrote:
>> Did I? I thought the point was to create a Singleton without a
>> constructor property. Asen - what was your meaning?
>
> I mean:
>
> - Doesn't have [[Construct]] method and `Singleton` cannot be use as
> part of `new Singleton()` expression.

It's not clear to me, though, if any of the suggestions made in this
thread -- Thomas Lahn's, mine, or your own -- meet your needs. Are
you still looking for a solution to your problem or have you found
one? I know you're not the OP, but it's your criteria that has
generated most of the discussion.

-- Scott
From: Thomas 'PointedEars' Lahn on
Garrett Smith wrote:

> Thomas 'PointedEars' Lahn wrote:
>> Garrett Smith wrote:
>>> Thomas 'PointedEars' Lahn wrote:
>>>> Garrett Smith wrote:
>>>>> Scott Sauyet wrote:
>>>>>> On Jan 25, 3:50 pm, Asen Bozhilov <asen.bozhi...(a)gmail.com> wrote:
>>>>>>> I want Singleton with properties:
>>>>>>> - Doesn't have constructor
>
> I take it he wants a Singleton without a constructor property. Did I get
> that wrong?

I do not know. He did not write `constructor *property*', so ...

>>>>> Why not?
>>>> The question is pointless; it simply cannot be done. Every object
>>>> has a constructor, even those created with initializers.
>>> Not every object will have constructor.
>>
>> True.
>>
>>> Even if changed to "Every native object", it would still not be true.
>>
>> True, the Global Object makes an exception there. There is no
>> description in the Specification how it is created; it is simply
>> "created before control enters any execution context" and then it "is
>> there".
>>
>>> Even if changed to "Every object except the global object," it would
>>> still not be true.
>>
>> Yes, it would. While maybe not accessible from ECMAScript code, host
>> objects need to have a constructor somewhere by which they have been
>> constructed.
>
> A host object is not required to have a constructor; not at least as far
> as a program is concerned.

If by "program" you mean _ECMAScript_ /Program/, then you are right;
otherwise not.

> I did interpret Asen's meaning of "I want Singleton with properties: -
> Doesn't have constructor" to mean that the object would not have a
> constructor property.

Yes, that is one possible interpretation. ISTM that the habit of East
Europeans of omitting articles in English is getting in the way here.

> I can't think of any reason why he would be making program requirements
> about unobservable implementation details.

The details do not have to be finally unobservable. AISB, objects created
with initializers have a constructor, too. The constructor of {} is (the
Function instance referred to by Object), the constructor of [] is Array,
and the constructor of /./ is RegExp; regardless whether there is a
`constructor' property on the instance or its prototype chain to refer to
it. If he would not be aware of that, this might be the reason for this
rather weird requirement of his (it would be a user-defined object and
AI(SH)SB, every user-defined object has a constructor).

> It sounds like you are interpreting the word "constructor" in general
> sense, to mean the thing that was new'd, and then further broadening
> that to include the implementation details of the Host. That seems to be
> broadening context of the discussion.

ISTM this discussion and all your examples are pointless without Asen
saying what he really meant.

> That is not what I interpreted. I read Asen's message as meaning
> "constructor" property, and as something observable by ECMAScript.

Yes, I got that already. No need of preaching to the choir ;-)

> An ECMAScript engine's implementation language is not something that the
> ECMA-262 gets to decide upon. That language is not required to have
> constructors, and so although the implementation most likely does (C,
> C++, Java), it is neither required nor observable.

However, if it is an *object*, it must have a constructor, regardless of
the programming language. That is how OOP works. Even the ECMAScript
Global Object needs to be constructed somehow -- it does not just appear
out of thin air.


PointedEars
--
realism: HTML 4.01 Strict
evangelism: XHTML 1.0 Strict
madness: XHTML 1.1 as application/xhtml+xml
-- Bjoern Hoehrmann
From: Asen Bozhilov on
Thomas 'PointedEars' wrote:

> Yes, that is one possible interpretation.  ISTM that the habit of East
> Europeans of omitting articles in English is getting in the way here.

You are right about my English. I know for people which English is
native, is very hard to reading my posts. Maybe if i read on my native
language - Bulgarian someone, which write like my on English i will be
ignoring. For East Europeans is hard to learn English, because
languages here and English are very different languages. However, i
make every endeavour to learn English and i hope soon my English to be
a better. I will be glad to write here without confusions like this.
Apologize to all members of c.l.js.


> ISTM this discussion and all your examples are pointless without Asen
> saying what he really meant.

I was write already. I'm not meant `constructor` property, which is
resolve from Prototype chain. I mean internal [[Construct]] method. I
don't want `object' referring from `Singleton` to be used as part of
`new Singleton();` expression. Object literal allow me to do it
that.