G
Garrett Smith
I take it he wants a Singleton without a constructor property. Did I get
that wrong?
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.
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).
Did I? I thought the point was to create a Singleton without a
constructor property. Asen - what was your meaning?
that wrong?
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".
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?