O
optimistx
How to write code for an example in the ECMAScript standard?
ECMAScript Standard ECMA-262 , 3rd edition (December 1999) is available as
pdf-file (size 720 951 bytes) to download at
(1)
http://www.ecma-international.org/publications/standards/Ecma-262.htm
and inofficial html version eg. at
(2)
http://interglacial.com/javascript_spec/
The only figure in the whole standard is on page 3, and can be seen on this
page
(3)
http://interglacial.com/javascript_spec/a-4.html#a-4.2.1
In order to learn the standard I tried to write beautiful and intuitive
javascript code for the example, which is described in the figure in the
link(3) above.
I used the notations in the figure (CF, Cfp, cf1, cf2, cf3, cf4, cf5 and
their properties prototype, P1, CFP1, q1, q2).
The text description and the figure do not agree completely: the text
mentions property P2 of CF, but it is not in the figure. (can there be an
error in the standard!?)
Yesterday I tried hours(!) with firefox and its debugger firebug, and
checked with chrome. I tried numerous alternatives to define functions,
objects (are they the same?), and putting properties to them so that the
objects cf1 ... cf5 would have their expected properties in the end. Some of
the alternatives 'worked' and some did not, but I do not know yet exactly,
why. Just now the state of this project and my mind is total confusion .
Objects and functions look very different in code, and intuitively I cannot
understand how they can be the same beasts, or are they? Eg.
function CF () {var P1='P1';this.q1='q1';this.q2='q2'}
var CFP = CFP1:'CFP1'}
var CF = function(){ };
var cf1 = new CF;
Firebug seemed to accept expressions new CF and new CF() happily. And that
after having learnt, that CF and CF() mean completely different things, and
not understanding the difference leads to difficult errors!
The order of executing statements, and where defining things seemed to lead
different results (cf3['CFP'] === ? )
It would be nice to try many correct ways to write code for the figure, AND
some intuitive but incorrect ways ... Also the explanations, why to write so
and why not. Yes I know these are partly matters of style, but too much
freedom is not good (why do the same thing in 7 different ways in one
project when 1 would suffice?).
Thoughts?
ECMAScript Standard ECMA-262 , 3rd edition (December 1999) is available as
pdf-file (size 720 951 bytes) to download at
(1)
http://www.ecma-international.org/publications/standards/Ecma-262.htm
and inofficial html version eg. at
(2)
http://interglacial.com/javascript_spec/
The only figure in the whole standard is on page 3, and can be seen on this
page
(3)
http://interglacial.com/javascript_spec/a-4.html#a-4.2.1
In order to learn the standard I tried to write beautiful and intuitive
javascript code for the example, which is described in the figure in the
link(3) above.
I used the notations in the figure (CF, Cfp, cf1, cf2, cf3, cf4, cf5 and
their properties prototype, P1, CFP1, q1, q2).
The text description and the figure do not agree completely: the text
mentions property P2 of CF, but it is not in the figure. (can there be an
error in the standard!?)
Yesterday I tried hours(!) with firefox and its debugger firebug, and
checked with chrome. I tried numerous alternatives to define functions,
objects (are they the same?), and putting properties to them so that the
objects cf1 ... cf5 would have their expected properties in the end. Some of
the alternatives 'worked' and some did not, but I do not know yet exactly,
why. Just now the state of this project and my mind is total confusion .
Objects and functions look very different in code, and intuitively I cannot
understand how they can be the same beasts, or are they? Eg.
function CF () {var P1='P1';this.q1='q1';this.q2='q2'}
var CFP = CFP1:'CFP1'}
var CF = function(){ };
var cf1 = new CF;
Firebug seemed to accept expressions new CF and new CF() happily. And that
after having learnt, that CF and CF() mean completely different things, and
not understanding the difference leads to difficult errors!
The order of executing statements, and where defining things seemed to lead
different results (cf3['CFP'] === ? )
It would be nice to try many correct ways to write code for the figure, AND
some intuitive but incorrect ways ... Also the explanations, why to write so
and why not. Yes I know these are partly matters of style, but too much
freedom is not good (why do the same thing in 7 different ways in one
project when 1 would suffice?).
Thoughts?