On May 23, 11:52 am, John G Harris wrote:
> On Thu, 20 May 2010 Richard Cornford wrote:
>>On May 20, 4:18 pm, John G Harris wrote:
>>> On Wed, 19 May 2010 at 09:22:43, Richard Cornford wrote:
>>>> while you can observe the
>>>> modification to an object and conclude that there must
>>>> be some 'referencing' mechanism that has all values that
>>>> are objects 'referring' to the single object
>>> <snip>
>>> Have you found the words in ECMA 262 that actually say
>>> that? If you have please tell me where as I haven't. It
>>> seems to be 'common knowledge' but not explicit.
>
>> The words that actually say what exactly? There are no
>> words in the spec that say "can ... conclude", the ability
>> to do that as a result of the observation is evidently a
>> fact (as at least one person has done so).
>
> Yes, I didn't say it very clearly. I want to know which words
> in ECMA 262 say that you can get at the insides of the same
> object via two different variables. I've finally managed to
> plough through the many sections of the standard needed to
> find the answer.
That will save me having to look up all the references in that spec.
> Suppose you execute these two statements :
>
> b = new Object();
> c = b;
>
> and follow the formal ES3 definitions of what will happen. After
> tracing through all the gets, puts, returns, etc. you will find
> that the 'value' of b *is* the newly created object, and the
>'value' of c is also that same object. Thus any change to the
> insides of the new object made via b is also visible via c.
>
> Obviously, the meaning of 'value' in ECMAScript is somewhat
> different to its meaning in other languages.
Probably at least some other languages, maybe most (I don't want to
think about that at the moment). We have a situation where a value can
be an object; the object *is* a value. We can be pretty sure, from
experience of how computers work, that an implementation is going to
be achieving that by employing some sort of reference, but that isn't
a concern of ECMAScript itself. ECMAScript stops at asserting that
objects are values.
> If 'value' seems confusing then we can turn to the informal ES3
> Overview section where properties are said to be containers.
> Each property, and so each variable, is said to contain either
> a primitive value or an object. Thus both b and c contain the
> same newly created object in the same way that both New York
> and North America contain Wall Street.
Wouldn't you b and c example above be better paralleled with, say,
Boston and New York both containing Wall Street?
> Unlike real geography,
I don't think geography is going to prove that useful in this case.
> an object can indirectly contain itself,
> making life difficult for the garbage collector.
>
> If you ask whether function arguments are passed by this or by
> that or by something else in ECMAScript the only correct answer
> is that all arguments are passed by containment.
Are they? If we accept 'properties "contain" values (so may contain
objects as objects are values)' then if the mechanics of passing
arguments to function calls does not involve properties of objects (at
any distinct step) then they will not be contained at that point, and
may not be being "passed by containment". (I may propose that at the
point of the having the result of the call to the internal GetValue
function in the algorithm for evaluating an Arguments list (11.2.4
(3rd Ed.)) represents having only the value, without any 'container'.)
Suppose we attempt to address this question form the other end, and
instead of worrying about how an argument is passed to a function call
instead look at how a function call receives its arguments. In
ECMAScript terms a function call always 'receives its arguments as
(ECMAScript) values'. This is guaranteed by the GetValue call in the
Arguments list algorithm, and it is here that the implications for the
possible 'passing on' of - this - values come from (there can be no
Reference types received as arguments to function calls).
> Any disagreement can only be about which feature of which
> other language it most closely resembles.
While that disagreement is evident I doubt that will prove the "only"
subject of disagreement.
> The ES5 standard adds much complication to the formal definitions
> but appears to make no essential difference to these conclusions.
That is my impression too.
Richard.
|