Inform you about the next translation:
"ECMA-262-3 in detail. Chapter 8. Evaluation strategy."
http://dmitrysoshnikov.com/ecmascript/chapter-8-evaluation-strategy/
Hi Dmitry,
1.- In the section "General Theory" you could as well say that the
order in which the arguments are evaluated in well specified in ES
(unlike in other languages, notably, C), it is from left to right.
This is of great importance if you happen to code something like this:
foo(a++, a+b);
2.- Pass-by-xxx and call-by-xxx can be used interchangeably. I would
stick to one of them. In the "Introduction" you use the term passed by
but in the sections you use call by. I for one would prefer "pass by"
everywhere as it's used more commonly than "call by", and I find it
more intuitive.
3.- Wrt the behaviour described in "Call by reference", let me tell
you that the behaviour when passing by reference an object in C is
exactly the same as in ECMAScript [*1]. C's behaviour has always been
called pass by reference, even though the reference is passed by
value. E.g. the wikipedia article about this says : "Even among
languages that don't exactly support call-by-reference, many,
including C and ML, support explicit references (objects that refer to
other objects), such as pointers (objects representing the memory
addresses of other objects), and these can be used to effect or
simulate call-by-reference (but with the complication that a
function's caller must explicitly generate the reference to supply as
an argument).". I would add, "and with the complication that the
pointer has to be dereferenced explicitly in order to access the
object".
4.- "Call by sharing" would be the best way to call it, were it not
for the fact that the semantics it describes get different names
depending on where you come from, some call it pass-by-reference and
some call it pass-by-value, because in fact it's both of them at the
same time: it's a "call-by-value, where the value is implied to be a
reference to the object". Exactly what C does, and what we've been
calling to pass by reference for ~ 4 decades.
5.- In "Terminology versions" you say
<quote>
The statement "objects are passed in function by reference" formally
is not related with ECMAScript and is incorrect.
</quote>
It is not anymore incorrect than saying that "in C objects can be
passed by reference" or "in Ruby objects are passed by reference" or
"in Java objects are passed by value, where the value is a reference".
I think that this matter is turning into a kind of holy war. If I were
to write on this matter, I would avoid any attempt to force a
terminology for as you should see there are good reasons for using any
of them, and different people coming from different languages are used
to call it differently, and none of them is wrong.
[*1] If you're interested, I can provide you an example that proves
this point. What you say in "By sharing and pointers" :
<quote>
Regarding ó/ó++, this strategy is ideologically similar to passing by
pointer values, but with one important difference -- that it is
possible to dereference the pointer and to change the object
completely.
</quote>
is wrong. In C, an argument that is a pointer is a copy of a
reference, just as an argument that is a reference in ES. When a
function receives an argument that is a pointer, it can either change
the argument's value alltogether and make it point to somewhere/
something else (in ES that would be the equivalent of assigning a
completely different value to the argument, as in reference= {}, or
reference= "fjh", or reference= 27, or reference= null, or reference=
youNameIt) or touch the contents of the object that the pointer points
to using a dereferencing operator, either pointer->property= value or
(*pointer).property= value, exactly as you'd do in ES, the only
difference being that in ES there's no need to dereference explicitly:
reference.property= value would do. There's *nothing* that can be done
in C when passing an object by reference (as in f(&object) ), that
can't be done in ES. Their behaviours are identical. And again. This
behaviour has been called "to pass by reference" for decades.