Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsGeneralPHPASPPerlColdFusionFlashHTML, CSS, ScriptsBrowsers

Webmaster Forum / HTML, CSS, Scripts / JavaScript / December 2005



Tip: Looking for answers? Try searching our database.

How to list the statement of all var ?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Thierry Loiseau - 26 Dec 2005 14:04 GMT
Hello all,

and Happy end year 2005 !

Well, I would like to obtain a list of all JavaScript var statement,
With "for...in" perharps ?

That is bellow my recent test here, but the problem is to management
theses :-((( I must to declare and use all variable with this scheme :

v['name']

Thanx for all suggestion !

========================================================================
<html>
<head>
<title>for...in (var)</title>
</head>
<body>
<script type="text/javascript">
<!--
var v=new Array();
v['titi']="";
v['bleah']='toto';
v['toto']='bibi';
v['tutu']=109;
v['annonce_fr']="Bonne f&ecirc;tes de fin d'ann&eacute;e !";
v['annonce_en']="Happy new year, this is the end of the year 2005...
Hello 2006 !!";
function print_all() {
 for (var i in window.v) {
  v['titi']=(typeof(window.v[i])=="string")?" ' ":"";
  document.write(i + " = " + v['titi'] +
  "<span style='color: blue; font-weight:bold;'>"+window.v[i]+"</span>"
+
  v['titi'] + "<br>\n");
 }
}
print_all();
document.write("<hr> v['tutu']+2 = "+(v['tutu']+2));
// -->
</script>
</body>
</html>
========================================================================

Thierry
and best regards from France,

<http://www.google.com/maps?ll=45.128319,1.306686&spn=0.005925,0.013087&
t=k&hl=fr>

PS : sorry for my bad english spoken :-(
Martin Honnen - 26 Dec 2005 14:53 GMT
> Well, I would like to obtain a list of all JavaScript var statement,
> With "for...in" perharps ?
[quoted text clipped - 3 lines]
>
> v['name']

The var statement declares a variable (or more) and might additionally
initialize variables e.g.
  var varName;
or
  var varName = 'Kibology';

v['name'] is a property access but obviously no var statement.

The language itself does not have a "Code object model" which would
allow your script code to access the code itself in a structured way
where you could look for statements or statements of a certain type.

But global variables declared with the var statement will become
properties of the global object (which is the window object in
client-side browser script) and properties of an object can be
enumerated using the for..in statement if those properties are not
marked with the internal attribute DontEnum. As the var statement
definition does not specify that that internal DontEnum attribute should
be set for declared variables being created as properties an
implementation should make all those declared variables enumerable with
for..in.

Signature

    Martin Honnen
    http://JavaScript.FAQTs.com/

Thierry Loiseau - 26 Dec 2005 15:05 GMT
> The var statement declares a variable (or more) and might additionally
> initialize variables e.g.

I'm shure "statement" is no well come in my first message :-(((
In french, "Etat" ?

Thierry
Martin Honnen - 26 Dec 2005 15:26 GMT
>>The var statement declares a variable (or more) and might additionally
>>initialize variables e.g.
>
> I'm shure "statement" is no well come in my first message :-(((
> In french, "Etat" ?

Sorry, I can't help, there is a French group fr.comp.lang.javascript as
far as I know where French is the main language, posting and reading
there might be more successful for you.
Google has it here:
<http://groups.google.com/group/fr.comp.lang.javascript?hl=en>
Hmm, I see you already post there, if that really does not help and you
want to post here then consider making a post with two languages,
English and French, here, that might then increase your chances that
someone here understands what you are looking for as you might have
someone read here who is fluent (enough) in French.

Signature

    Martin Honnen
    http://JavaScript.FAQTs.com/

VK - 26 Dec 2005 20:15 GMT
> > The var statement declares a variable (or more) and might additionally
> > initialize variables e.g.
>
> I'm shure "statement" is no well come in my first message :-(((
> In french, "Etat" ?

"a state" - but this is a too vague term for the task description.
Based on the posted code you're trying to find either "valeur" (a
value) or "typage" (a type) - or both - of the v[i] elements. Could you
clarify please?
( Any recognizable version of the Shakespeare language goes just fine
;-)
Thierry Loiseau - 26 Dec 2005 20:31 GMT
> > > The var statement declares a variable (or more) and might additionally
> > > initialize variables e.g.
[quoted text clipped - 3 lines]
>
> "a state" - but this is a too vague term for the task description.

Right ! Ok !

> Based on the posted code you're trying to find either "valeur" (a
> value) or "typage" (a type) - or both - of the v[i] elements. Could you
> clarify please?
> ( Any recognizable version of the Shakespeare language goes just fine
> ;-)

Ok. Thank you for your post. Than my example, I would like to get value
of each !

With my script =

========================================================================
<html>
<head>
<title>for...in (var)</title>
</head>
<body>
<script type="text/javascript">
<!--
var v=new Array();
v['titi']="";
v['bleah']='toto';
v['toto']='bibi';
v['tutu']=109;
v['annonce_fr']="Bonne nouvelle ann&eacute;e 2006 !!";
v['annonce_en']="Happy new year 2006 !!";
function print_all() {
 for (var i in window.v) {
  v['titi']=(typeof(window.v[i])=="string")?" ' ":"";
  document.write(i + " = " + v['titi'] +
  "<span style='color: blue; font-weight:bold;'>"+window.v[i]+"</span>"
+
  v['titi'] + "<br>\n");
 }
}
print_all();
document.write("<hr> v['tutu']+2 = "+(v['tutu']+2));
// -->
</script>
</body>
</html>
========================================================================

The result is :

========================================================================

titi = '  '  '
bleah = ' toto '
toto = ' bibi '
tutu = 109
annonce_fr = ' Bonne nouvelle année 2006 !! '
annonce_en = ' Happy new year 2006 !! '
v['tutu']+2 = 111
========================================================================

I repeat : the problem is to management theses :-(((
So, I must to declare and use all variable with this strict scheme
(syntax, scheme is a good word ?) :

v['name']

Thanx for all suggestion !

Thierry,
best regards from France
VK - 26 Dec 2005 21:05 GMT
> I repeat : the problem is to management theses :-(((
> So, I must to declare and use all variable with this strict scheme
> (syntax, scheme is a good word ?) :
>
> v['name']

Array ("rangee") consists of arrayObject.length elements and you handle
them by their index which is positive integer:
v[10] = 'foo';
alert(v[10]);

The posted structure is *not* an array. So proper way to handle it
would be (one of possibilities):

var v=new Object(); // not Array!
v['titi']="";
v['bleah']='toto';
v['toto']='bibi';
v['tutu']=109;
v['annonce_fr']="Bonne nouvelle ann&eacute;e 2006 !!";
v['annonce_en']="Happy new year 2006 !!";
etc. as you already do

And of course no one stops you from declaring separate variables which
are not parts of any higher structure:

var blah_blah_blah = "blah-blah-blah";

I guess you need to find a good French manual of JavaScript (I cannot
advise any).
For English reading you may visit:
<http://www.geocities.com/schools_ring/ArrayAndHash.html>

:-D   ;-)
Thierry Loiseau - 26 Dec 2005 21:17 GMT
> > I repeat : the problem is to management theses :-(((
> > So, I must to declare and use all variable with this strict scheme
[quoted text clipped - 11 lines]
>
> var v=new Object(); // not Array!

Ok !

> v['titi']="";
> v['bleah']='toto';
[quoted text clipped - 13 lines]
> For English reading you may visit:
> <http://www.geocities.com/schools_ring/ArrayAndHash.html>

Ok (too). So I make a long script to my (sorry in french) personal
homepage.

<http://astrophoto.free.fr/calculs/calculs.js>

> :-D   ;-)

Yep !

Thanx VK !

Thierry Loiseau
and Best regards
From France
VK - 26 Dec 2005 21:27 GMT
> So I make a long script to my (sorry in french) personal
> homepage.
>
> <http://astrophoto.free.fr/calculs/calculs.js>

Cool! So does everything work as expected now?

> > :-D   ;-)
>
> Yep !

Smilies were not to you directly, just a... conditional signature :-)
Thierry Loiseau - 26 Dec 2005 21:39 GMT
> > So I make a long script to my (sorry in french) personal
> > homepage.
> >
> > <http://astrophoto.free.fr/calculs/calculs.js>
>
> Cool! So does everything work as expected now?

From <http://astrophoto.free.fr/calculs/>
=> clic on button "simulateur copernic" and after onload, clic on
"astrophoto"... :-)))
=> clic on button "Lunes de Jupiter" and clic on the item "Repères", on
left, top, twice to view animation...

=> clic on button "visibilité des planètes", clic on the image-planete
then, there is a popup, and you see the position of this in the sky.
=> clic on button "astrophoto" to see the constelllation...

> > > :-D   ;-)
> >
> > Yep !
>
> Smilies were not to you directly, just a... conditional signature :-)

Argh, ok !-)

Best regards from France,

Thierry

PS : VK, do you speak french ?
Thierry Loiseau - 26 Dec 2005 21:19 GMT
> > I repeat : the problem is to management theses :-(((
> > So, I must to declare and use all variable with this strict scheme
[quoted text clipped - 11 lines]
>
> var v=new Object(); // not Array!

Ok ! But my script run with a good result, no ?

> v['titi']="";
> v['bleah']='toto';
[quoted text clipped - 13 lines]
> For English reading you may visit:
> <http://www.geocities.com/schools_ring/ArrayAndHash.html>

Ok (too). So I make a long script to my (sorry in french) personal
homepage.

<http://astrophoto.free.fr/calculs/calculs.js>

> :-D   ;-)

Yep !

Thanx VK !

Thierry Loiseau
and Best regards
From France
RobG - 27 Dec 2005 00:18 GMT
[...]

>>The posted structure is *not* an array. So proper way to handle it
>>would be (one of possibilities):
>>
>>var v=new Object(); // not Array!
>
> Ok ! But my script run with a good result, no ?

Because Arrays are Objects, so you can do with them everything that
you can do with ordinary objects.

Arrays are a special objects with a property 'length' and a number of
special methods - splice, push, pop, concat et cetera - but otherwise
they are just like other objects.

VK suggested using an ordinary object because you weren't using the
special property or methods of an array.

[...]

Signature

Rob

VK - 27 Dec 2005 12:01 GMT
> Ok ! But my script run with a good result, no ?

It does... until when... because any JavaScript/JScript objext extends
Object constructor.

By the usage twist it is similar to:

function f1() {
with (arguments.callee) {
 return arg1 + arg2;
}
}

f1.arg1 = 2;
f1.arg2 = 2;
alert(f1());

Here too you're declaring *function* f1 but overloading it as a
primitive Object. JavaScript is flexible enough for such and even more
weird things, but not would it be better to use the conventional way?

function f1(arg1, arg2) {
return arg1+arg2;
}

alert(f1(2,2));

You need to use hacks only when you have too. Otherwise you should use
the things with the intended purposes and in the intended way.
IMHighlyHO
Thomas 'PointedEars' Lahn - 27 Dec 2005 12:34 GMT
>> Ok ! But my script run with a good result, no ?
>
> It does... until when... because any JavaScript/JScript objext extends
> Object constructor.

Wrong.  What you maybe meant to say was that user-defined objects
inherit properties from the Object prototype which would be disabled
for an inheriting object as long as their name would be used as name
of a property of that object.

> By the usage twist it is similar to:
>
[quoted text clipped - 10 lines]
> Here too you're declaring *function* f1 but overloading it as a
> primitive Object.

Nothing is "overloaded" here.  As in functional programming languages,
functions _are_ (first-class) objects in J(ava)Script/ECMAScript:
Function objects.  Neither objects nor references are primitive values.

PointedEars
VK - 27 Dec 2005 21:30 GMT
> > VK wrote:
> > It does... until when... because any JavaScript/JScript objext extends
> > Object constructor.

>Thomas 'PointedEars' Lahn wrote:
> Wrong.  What you maybe meant to say was that user-defined objects
> inherit properties from the Object prototype which would be disabled
> for an inheriting object as long as their name would be used as name
> of a property of that object.

Programming entities: Evolutionism or Creationism? :-)

I'm staing exclusively on the Evolutionism position here. There is the
initial protozoa Object() and everything else are branches of evolution
from this starting point. Date(), String(), Array(), myObject(),
myOtherObject() are all equally coming that protozoa despite their
evolution branches (thus property sets) can be twisted in the most
amazing ways.

Therefore arguments like "Array() is almost like Object() so no big
deal what to use" to me sounds like "daschund is really same kind as
buldog so no big deal what to buy".

I accept the possibility of other theories including the promoted
Selective Creationism, there all things are by themselves, and some
things should be considered as one entity (despite some differences)
because they've been created by Them to be one thing.

I still believe that my God is better :-)

> Nothing is "overloaded" here.
I guess my usage of "overload" is not canonical. For me it's a way to
use the "other side" of things. Like create Array() and use it as
associative array via Object() side. Or store Function() arguments in
its Object() background (like in my sample), or force plus to works as
minus - something like this.
Thomas 'PointedEars' Lahn - 27 Dec 2005 21:39 GMT
>> > VK wrote:
>> > It does... until when... because any JavaScript/JScript objext extends
>> > Object constructor.
>
>> Thomas 'PointedEars' Lahn wrote:

I thought you finally learned how to quote.

>> Wrong.  What you maybe meant to say was that user-defined objects
>> inherit properties from the Object prototype which would be disabled
>> for an inheriting object as long as their name would be used as name
>> of a property of that object.
>
> Programming entities: Evolutionism or Creationism? :-)

That is not a matter of philosophy or belief.  The statement that
"JavaScript/JScript obje[c]t extends [the] Object constructor" is
simply wrong.

>> Nothing is "overloaded" here.
> I guess my usage of "overload" is not canonical.  [...]

Surprise, surprise!

PointedEars
VK - 27 Dec 2005 12:22 GMT
> > The posted structure is *not* an array. So proper way to handle it
> > would be (one of possibilities):
> >
> > var v=new Object(); // not Array!

> Ok ! But my script run with a good result, no ?

It does... until when... because any JavaScript/JScript objext extends
Object constructor.

So by the usage twist it is similar to:

function f1() {
with (arguments.callee) {
 return arg1 + arg2;
}
}

f1.arg1 = 2;
f1.arg2 = 2;
alert(f1());

Here too you're declaring a "Function* object but using it as an Object
object. JavaScript is flexible enough for even more tricky things. But
wouldn't it be better to use the conventional way:

function f1(arg1, arg2) {
return arg1 + arg2;
}

alert(f1(2,2));

You should use hacks only if you have too otherwise you should use
things in the conventional way with the conventional purpose.
IMHighlyHO
Thierry Loiseau - 26 Dec 2005 20:35 GMT
> > > The var statement declares a variable (or more) and might additionally
> > > initialize variables e.g.
[quoted text clipped - 3 lines]
>
> "a state" - but this is a too vague term for the task description.

Right ! Ok !

> Based on the posted code you're trying to find either "valeur" (a
> value) or "typage" (a type) - or both - of the v[i] elements. Could you
> clarify please?
> ( Any recognizable version of the Shakespeare language goes just fine
> ;-)

Ok. Thank you for your post. Than my example, I would like to get value
of each !

With my script =

========================================================================
<html>
<head>
<title>for...in (var)</title>
</head>
<body>
<script type="text/javascript">
<!--
var v=new Array();
v['titi']="";
v['bleah']='toto';
v['toto']='bibi';
v['tutu']=109;
v['annonce_fr']="Bonne nouvelle ann&eacute;e 2006 !!";
v['annonce_en']="Happy new year 2006 !!";
function print_all() {
 for (var i in window.v) {
  v['titi']=(typeof(window.v[i])=="string")?" ' ":"";
  document.write(i + " = " + v['titi'] +
  "<span style='color: blue; font-weight:bold;'>"+window.v[i]+"</span>"
       + v['titi'] + " [" + typeof(window.v[i]) + "]<br>\n");
 }
}
print_all();
document.write("<hr> v['tutu']+2 = "+(v['tutu']+2));
// -->
</script>
</body>
</html>
========================================================================

The result is :

========================================================================

titi = '  '  '
bleah = ' toto '
toto = ' bibi '
tutu = 109
annonce_fr = ' Bonne nouvelle année 2006 !! '
annonce_en = ' Happy new year 2006 !! '
v['tutu']+2 = 111
========================================================================

I repeat : the problem is to management theses :-(((
So, I must to declare and use all variable with this strict scheme
(syntax, scheme is a good word ?) :

v['name']

Thanx for all suggestion !

Thierry,
best regards from France
Thierry Loiseau - 26 Dec 2005 20:39 GMT
> > > The var statement declares a variable (or more) and might additionally
> > > initialize variables e.g.
[quoted text clipped - 3 lines]
>
> "a state" - but this is a too vague term for the task description.

Right ! Ok !

> Based on the posted code you're trying to find either "valeur" (a
> value) or "typage" (a type) - or both - of the v[i] elements. Could you
> clarify please?
> ( Any recognizable version of the Shakespeare language goes just fine
> ;-)

Ok. Thank you for your post. Than my example, I would like to get value
of each !

With my script =

========================================================================
<html>
<head>
<title>for...in (var)</title>
</head>
<body>
<script type="text/javascript">
<!--
var v=new Array();
v['titi']="";
v['bleah']='toto';
v['toto']='bibi';
v['tutu']=109;
v['annonce_fr']="Bonne nouvelle ann&eacute;e 2006 !!";
v['annonce_en']="Happy new year 2006 !!";
function print_all() {
 for (var i in window.v) {
  v['titi']=(typeof(window.v[i])=="string")?" ' ":"";
  document.write(i + " = " + v['titi'] +
  "<span style='color: blue; font-weight:bold;'>"+window.v[i]+"</span>"
       + v['titi'] + " [" + typeof(window.v[i]) + "]<br>\n");
 }
}
print_all();
document.write("<hr> v['tutu']+2 = "+(v['tutu']+2));
// -->
</script>
</body>
</html>
========================================================================

The result print in the page is :

========================================================================
titi = '  '  ' [string]
bleah = ' toto ' [string]
toto = ' bibi ' [string]
tutu = 109 [number]
annonce_fr = ' Bonne nouvelle année 2006 !! ' [string]
annonce_en = ' Happy new year 2006 !! ' [string]
v['tutu']+2 = 111
========================================================================

I repeat : the problem is to management theses :-(((
So, I must to declare and use all variable with this strict scheme
(syntax, scheme is a good word ?) :

v['name']

Thanx for all suggestion !

Thierry,
best regards from France
Jasen Betts - 26 Dec 2005 20:24 GMT
>> The var statement declares a variable (or more) and might additionally
>> initialize variables e.g.
>
> I'm shure "statement" is no well come in my first message :-(((
> In french, "Etat" ?

I know very little French, "Etat" is like the english word "nation" ???

"a statement" is like "a thing said"

"var statement" in this context is a piece of javascript
that that starts with "var"

example:

var a=10,b=20;

Bye.
  Jasen
Thierry Loiseau - 28 Dec 2005 18:59 GMT
> I know very little French, "Etat" is like the english word "nation" ???

Yep ! Sorry, I would like to write "état". Of course !-)
Zwetan, comment traduis-tu ce terme ?

Merci beaucoup à tous !

Thierry
zwetan - 28 Dec 2005 19:45 GMT
> > I know very little French, "Etat" is like the english word "nation" ???
>
> Yep ! Sorry, I would like to write "état". Of course !-)
> Zwetan, comment traduis-tu ce terme ?

I would translate it as "state" or perharps "status"

so to nail down this translation problem

"to list the state of all var"
can be interpreted as
listing the values of variables corresponding to their variable names
(and is possible to obtain in code with a for...in)

"to list the statement of all var"
could be interpreted as
listing the syntax notation that has been used to declare the variables
(and this is not possible from client code, possible if you modify the
script engine
which I think is not the goal here)

zwetan
zwetan - 27 Dec 2005 16:59 GMT
Hello,

> Well, I would like to obtain a list of all JavaScript var statement,
> With "for...in" perharps ?
[quoted text clipped - 5 lines]
>
> Thanx for all suggestion !
[snip]

If you want to trace into an associative Array, use an object Object instead

in FF for ex:
---------------
var v=new Object();
v['titi']="";
v['bleah']='toto';
v['toto']='bibi';
v['tutu']=109;
v['annonce_fr']="Bonne f&ecirc;tes de fin d'ann&eacute;e !";
v['annonce_en']="Happy new year, this is the end of the year 2005...Hello
2006 !!";

document.write( "v:"+v.toSource() );
---------------

will trace
---------------
v:({titi:"", bleah:"toto", toto:"bibi", tutu:109, annonce_fr:"Bonne fêtes
de fin d'année !", annonce_en:"Happy new year, this is the end of the year
2005...Hello 2006 !!"})
---------------

if you want the same functionality in any browser you can also use my core2
library
http://www.burrrn.com/projects/core2.html

here an exemple
---------------
<html>
<body>
<head>
<script type="text/javascript" src="core2_v1.0.0_JS.js"></script>

<style type="text/css">

html
   {
   height: 100%;
   overflow: hidden;
   }

body
   {
   height: 100%;
   margin: 0;
   padding: 0;
   background-color: #FFFFFF;
   }

#TraceConsole
   {
   width: 600px;
/*  height: 400%; */
   text-align: left;
   font-size: 12px;
/*  font-family: monospace; */
/*  font-family: tahoma, Verdana, Helvetica, Sans-Serif; */
   font-family: courier,fixed,swiss,sans-serif;
   border: 1px dotted #cccccc;
   display: block;
   }

</style>
</head>
<title>blah</title>
<html>
<div id="TraceConsole"></div>
<script type="text/javascript">

var v=new Object();
v['titi']="";
v['bleah']='toto';
v['toto']='bibi';
v['tutu']=109;
v['annonce_fr']="Bonne f&ecirc;tes de fin d'ann&eacute;e !";
v['annonce_en']="Happy new year, this is the end of the year 2005...Hello
2006 !!";

trace( "v:"+v.toSource( 0 ) );

</script>

</body>
</html>
---------------

will trace in the DIV
---------------
v:
   {
   titi:"",
   bleah:"toto",
   toto:"bibi",
   tutu:109,
   annonce_fr:"Bonne fêtes de fin d\'année !",
   annonce_en:"Happy new year, this is the end of the year 2005...Hello
2006 !!"
   }
---------------

Alternatively you could also use another way of organizing your local
strings

for exemple:
---------------
var AnnounceStrings = new Object();
AnnounceStrings.fr  = new Object();
AnnounceStrings.en  = new Object();

AnnounceStrings.fr.happyNewyear = "Bonne f&ecirc;tes de fin d'ann&eacute;e
!";
AnnounceStrings.fr.hello        = "bonjour {0}";

AnnounceStrings.en.happyNewyear ="Happy new year, this is the end of the
year 2005...Hello 2006 !!";
AnnounceStrings.en.hello        = "hello {0}";

trace( "AnnounceStrings:"+AnnounceStrings.toSource( 0 ) );

var userName = "toto";
var lang     = "fr";

trace( "--------" );
trace( String.format( AnnounceStrings[ lang ].hello, userName ) );
---------------

will trace in the DIV
---------------
AnnounceStrings:
   {
   fr:
       {
       happyNewyear:"Bonne fêtes de fin d\'année !",
       hello:"bonjour {0}"
       },
   en:
       {
       happyNewyear:"Happy new year, this is the end of the year
2005...Hello 2006 !!",
       hello:"hello {0}"
       }
   }
--------
bonjour toto
---------------

HTH
zwetan
Thomas 'PointedEars' Lahn - 27 Dec 2005 19:04 GMT
>> Well, I would like to obtain a list of all JavaScript var statement,
>> With "for...in" perharps ?

Please provide attribution of quoted material:

<URL:http://jibbering.com/faq/faq_notes/pots1.html#ps1Post>

>> That is bellow my recent test here, but the problem is to management
>> theses :-((( I must to declare and use all variable with this scheme :
[quoted text clipped - 5 lines]
> If you want to trace into an associative Array, use an object Object
> instead

Probably you meant to say "There are no associative Arrays in JS/ECMAScript.
What is achieved with associative arrays in other languages, is provided by
properties of objects and property accessors here."

> in FF for ex:
> ---------------
[quoted text clipped - 16 lines]
> 2005...Hello 2006 !!"})
> ---------------

No, it will not always, unless toSource() is user-defined.

> if you want the same functionality in any browser

You meant to say "with any script engine" but even that would not be true.

> you can also use my
> core2 library
[quoted text clipped - 5 lines]
> <body>
> <head>

Invalid examples are worthless.  <URL:http://validator.w3.org/>

> will trace in the DIV

IMHO, "tracing" is following traces, such as a stack trace where one call
on the stack leads to the next.  So I do not see any tracing here, let alone
the "core2" library fulfilling its self-imposed requirement of "same API
everywhere (JavaScript, JScript, ActionScript, etc.)", considering e.g.
the untested use of document.getElementById() and proprietary `.innerHTML'.
I also see other examples of bad code style: an undeclared variable just to
call a function and then `delete' it, bad indentation, error-prone property
inference and so on.  Certainly something that will make your day
interesting.

PointedEars
___________
[1] See <URL:http://en.wikipedia.org/wiki/Trace>, Computing, which you often
   like to refer to on your Web site.
zwetan - 28 Dec 2005 04:39 GMT
> >> Well, I would like to obtain a list of all JavaScript var statement,
> >> With "for...in" perharps ?
>
> Please provide attribution of quoted material:
>
> <URL:http://jibbering.com/faq/faq_notes/pots1.html#ps1Post>

from my post I think is pretty clear to whom I answser (1 single poster)
cf
"Material quoted from the previous message is attributed to its author and
indented with a marker character (usually >). "

anyway point taken as you can see in the first line of this post.

> Probably you meant to say "There are no associative Arrays in JS/ECMAScript.
> What is achieved with associative arrays in other languages, is provided by
> properties of objects and property accessors here."

Well I didn't get into all the details indeed,
yes there are no real associative Array in ECMAScript,
but you can obtain a similar functionality of associative Array using object
Object

but as I prefer to stay on topic, which if I remember well was
"I would like to obtain a list of all JavaScript var statement"

why should I go all the way to explain in lenghty details
the subtle differences between associative arrays and indexed arrays ?

Why don't you go into those details if you think these explanations are
missing
and should be stated to undertand better the problem at stake ?

for people interested in all the subtleties of Arrays in ECMAScript
I would advise those links
http://blogs.msdn.com/ericlippert/archive/2003/11/10/53376.aspx
http://blogs.msdn.com/ericlippert/archive/2003/11/12/53377.aspx
http://blogs.msdn.com/ericlippert/archive/2003/11/14/53383.aspx
http://blogs.msdn.com/ericlippert/archive/2003/11/21/53399.aspx
http://blogs.msdn.com/ericlippert/archive/2003/12/05/53452.aspx

Eric Lippert talk about the difference of implementation of Arrays in
JScript.NET
compared to JScript, but it can still be very usefull to apply this
knowledge
in other ECMAScript hosts, but as you can see the topic can be quite
lengthy.

> > in FF for ex:
[snip]

> No, it will not always, unless toSource() is user-defined.

"in FF" mean "in FireFox"...
you don't need to define the toSource method in  FireFox afaik
it's natively implemented in the SpiderMonkey engine.
(and please don't point that I don't provide the exact version of the
engine)

I could understand that someone could not be familiar with the "FF"
abbreviation,
but to attribute my use of this abbreviation as a way to make a false
statement
is going a little too far don't you think ?

> > if you want the same functionality in any browser
>
> You meant to say "with any script engine" but even that would not be true.

you know I just posted a comment to help someone,
I can not really phrase all my comments to suit your taste.

I meant "any browser" as "any browser host", as "any browser host
implementing ECMA-262 standard",
and I think you are really picky to jump on a detail like that.

Can you precise in what way "even that would not be true" ?
is it because of older browsers not implementing fully ECMA-262 3rd edition
or other browsers not implementing at all ECMA-262 and so not being able
to execute JavaScript ?

If for you my lack of details in my comment cause a problem,
you should a least apply this principle to your own comments,
just to not be vague as you apparently repproaching me.

I can accept critics, the problem with your comments is that you don't
explain clearly what your critic is about...

Yes off course "in any browser" was vague, but com'on
you know as me that not all ECMAScript implementations are made the same,
to discuss the problem of compatibility amongs all the browsers is a very
long thread in itself, I was just focusing on the problem that's all.

> > you can also use my
> > core2 library
[quoted text clipped - 7 lines]
>
> Invalid examples are worthless.  <URL:http://validator.w3.org/>

at least I provide an exemple, and yes I don't pass all code that I write
from the top of my head trough a validator first

as I don't syntax check all my newsgroups post

I inverted 2 HTML tags..big deal
as sometimes I can inverse letters in words too because I write too fast
hey I'm just human

What is worhtless imho is someone spending his valuable time
pointing finger to all my little errors as if every human were robots and
perfect

are we here to help someone solve a problem
or to start a fight on what is worthless or not ?

> > will trace in the DIV
>
[quoted text clipped - 3 lines]
> everywhere (JavaScript, JScript, ActionScript, etc.)", considering e.g.
> the untested use of document.getElementById() and proprietary `.innerHTML'.

You see "tracing" in a different way that I see it and also in a different
context.

core2 goal is to be able to run anywhere there is a compliant ECMA-262
interpreter,
you can not implement "stack trace" everywhere due to the ECMA-262 standard
itself
which let the implementation of Function.prototype.toString at the
discretion of the
implementors.

Some hosts can introspect function body, some other hosts can not do that,
that's why the choice of not implementing "stack trace" has been made.
It's a choice that fill the requirement of the library, if that philosophy
does not suit you
well the code is open source and you are free to make a patch/diff/fork/etc.
.

And even if it could have been possible to implement "stack trace" for every
host,
I would have named it as a global function "StackTrace" to show the
difference of behaviour.

core2 is also a library which focus on ECMAScript programming, not the DOM
programming.

If you had taken the time to read some comments on the code,
http://live.burrrn.com/browser/ECMA-262/core2/branches/core2_v1.0.x/src/buRRRn/c
ore2.js

you could haves seen this
" yes it's an ugly hack :) "

I don't claim at all that the trace function is efficient, I just claim it
works
as it is on those browsers and as an ugly hack
 a.. Mozilla, FireFox v1.0 (Windows)
 b.. Mozilla, Mozilla v1.7.5 (Windows)
 c.. Microsoft, Internet Explorer v6.0 (Windows)
 d.. Opera Software, Opera v8.5 (Windows)
so yes I don't test getElementById(), I test ECMAScript code
targeted to work in any ECMA-262 environments, not only browser DOM.

And yes the library does not work as it is for IE v5.0
or is not yet tested on some other hosts, etc.

It is clearly stated on the project page and then i don't think I induce
people in error.

Following some of your links I see that you have developped libraries on
your own also,
so I suppose you know that sometimes you have to make choices about what
features to implement or not and to what extend to implement them and to how
to implement them.

> I also see other examples of bad code style:
> an undeclared variable just to call a function and then `delete' it,

does this cause a bug ?

>bad indentation,

did you realize that the LIB releases have indeed their indentation striped
out
(as uncessary empty lines and code comments)
because their sole purpose are to be used as LIBraries,
if you want clean indented code with comments and all
you can check the DEVelopper releases,
or directly the source code in SVN.

> error-prone property inference and so on.

I would have been glad that you had filled a bug report if you had seen
errors or bugs
http://live.burrrn.com/newticket

but afaik with the current code base and the current sets of unit tests and
the current tested hosts
I  don't see any property inference, so if you can point where you see such
an error happening
I would just be happy to correct it.

If this comment is more about a difference of coding style, well...
I read some of your codes, you got your coding style
I understand why you do things like that
and I would not see myself to tell you that your coding style is bad
simply because you don't do things as I do.

The merit of a coding style is to be coherent amongs the whole code,
you are coherent amongs your code, I am coherent amongs my code,
doing things differently does not mean one way is better than another,
it's just a coding style.

> Certainly something that will make your day interesting.

I understand that you are posting here for a long time and I respect that
but even if that was my 1st post on this newsgroup (which is not the case)
I don't really find all your comments on this particular topic that much
interesting

I would have prefered more constructive comments, but that's just me.

> ___________
> [1] See <URL:http://en.wikipedia.org/wiki/Trace>, Computing, which you often
>     like to refer to on your Web site.

indeed the first line I read is "The word trace has several meanings" :)

with a little advance I wish you an happy new year 2006 PointedEars

live long and prosper

zwetan
Thomas 'PointedEars' Lahn - 28 Dec 2005 14:53 GMT
>> [...]
>> Probably you meant to say "There are no associative Arrays in
> JS/ECMAScript.
^^^^
Please get your NetNews posting software repaired:

<URL:http://insideoe.com/>

[repaired broken quotes]
>> What is achieved with associative arrays in other languages, is provided
>> by properties of objects and property accessors here."
[quoted text clipped - 5 lines]
>
> but as I prefer to stay on topic,

This is on-topic as long it is about JS/ECMAScript.

> which if I remember well was "I would like to obtain a list of all
> JavaScript var statement"
>
> why should I go all the way to explain in lenghty details
> the subtle differences between associative arrays and indexed arrays ?

Why should you provide something that returns the names of properties
of an object when the question was about `var' statements?

 var x, y, z;

should be _one_ entry in the requested list.  Of course that is not possible
with property accessors.

> Why don't you go into those details if you think these explanations are
> missing and should be stated to undertand better the problem at stake ?

Because it has already been discussed at great length here before.

> [...]
>> > in FF for ex:
>> No, it will not always, unless toSource() is user-defined.
>
> "in FF" mean "in FireFox"...

It does not work this way in Firefox (1.5) without prototype augmentation,
or in JavaScript for that matter, and it never has.

> you don't need to define the toSource method in  FireFox afaik

True, there is native prototype.toSource() for several core objects but
it does returns something different than you suggest in all cases.

> it's natively implemented in the SpiderMonkey engine.

Yes, but it does not do what you suggest.

> (and please don't point that I don't provide the exact version of the
> engine)

It does not and has never worked this way in any SpiderMonkey version.

>> > if you want the same functionality in any browser
>> You meant to say "with any script engine" but even that would not be
>> true.
>
> you know I just posted a comment to help someone,
> I can not really phrase all my comments to suit your taste.

Usage of exact terms are one important key to understanding.

> I meant "any browser" as "any browser host", as "any browser host
> implementing ECMA-262 standard",  [...]

It would have been true if you wrote "any language that is an
ECMAScript _3_ implementation."  What is a "browser host" anyway?

> Can you precise in what way "even that would not be true" ?
> is it because of older browsers not implementing fully ECMA-262 3rd
> edition or other browsers not implementing at all ECMA-262

Yes.

> and so not being able to execute JavaScript ?

The question conveys a misconception about ECMAScript and JavaScript.
ECMAScript (3) !== JavaScript (1.5).

>> > you can also use my
>> > core2 library
[quoted text clipped - 10 lines]
> at least I provide an exemple, and yes I don't pass all code that I write
> from the top of my head trough a validator first

If you are not able to write Valid markup from the top of your head (which
is a sure sign of insufficient experience), you should validate the result
first, because bad examples are copied by the uninitiated and end up in bad
code.

> as I don't syntax check all my newsgroups post

I do not either.  That is not the point.

> I inverted 2 HTML tags..big deal
> as sometimes I can inverse letters in words too because I write too fast
> hey I'm just human

The rest of your markup is not Valid, too.

> What is worhtless imho is someone spending his valuable time
> pointing finger to all my little errors as if every human were
> robots and perfect

/You/ _posted_ the example.

> are we here to help someone solve a problem
> or to start a fight on what is worthless or not ?

Examples with not Valid markup are worthless, because script code can only
operate reliably on Valid markup.  That is a fact, not something that can
or should be fought about.

>> > will trace in the DIV
>>
[quoted text clipped - 7 lines]
> You see "tracing" in a different way that I see it and also in a different
> context.

You are misusing the word.  There is nothing traced here at all.  Maybe
I would have concured if you provided a serialization of the properties,
that is, show what steps are executed or serialize each known property
value (including those that are not enumerable) until there would only
be primitive values.  That would be some kind of tracing, following the
trace from one property to the primitive value.  So a trace of

 x = {y: [/z/]};

could look like

 x = new Object();
 x.y = new Array();
 x.y[0] = new RegExp("z");

or

 x = {
   y: Array
      {
        "0": RegExp
             {
               ...
               source: "z"
               ...
             },
        length: 1
        ...
      }
 };

> core2 goal is to be able to run anywhere there is a compliant ECMA-262
> interpreter,

An implementation conforming to ECMAScript _Edition 3_.

> [...]

You are winding around the issue.

>> I also see other examples of bad code style:
>> an undeclared variable just to call a function and then `delete' it,
>
> does this cause a bug ?

No, but it rightfully causes a warning in the JavaScript console.  Variables
should be declared.  With your code, assuming an ECMAScript 3 compliant
script engine is used,

 (function(...)
  {
    // ...
  })(...);

sufficed.  There is no need for the undeclared global variable, hence
no need for `delete'.

>> bad indentation,
>
> did you realize that the LIB releases have indeed their indentation
> striped out
> (as uncessary empty lines and code comments)

No, but that is not the point.  You should and could have stripped it
better then.

> because their sole purpose are to be used as LIBraries,
> if you want clean indented code with comments and all
> you can check the DEVelopper releases,
> or directly the source code in SVN.

What are you talking about?

The developer release is just as badly indented:

| _global.trace = function( txt )
|     {
[quoted text clipped - 3 lines]
|        Better if you want to trace a lot in the large.
|        (yes it's an ugly hack :))

An ugly hack that is unnecessary, for `textarea' elements exist.

|     */
|     var tc = document.getElementById( "TraceConsole" );
[quoted text clipped - 6 lines]
|     */
|     }

>> error-prone property inference and so on.
>
[quoted text clipped - 4 lines]
> such an error happening
> I would just be happy to correct it.

The problem is that you tested with certain host environments and infer
from those special cases to the general one.  What your code is lacking
to be almost bullet-proof is a feature-test _on run-time_ that the used
features, particularly the used DOM features, are supported.

> [...]
> The merit of a coding style is to be coherent amongs the whole code,
> you are coherent amongs your code, I am coherent amongs my code,
> doing things differently does not mean one way is better than another,
> it's just a coding style.

That is not entirely true.  Bad code style usually is based on
misconceptions and often results in unreliable code and/or code
that is harder to maintain.

I could provide more examples of that right from your code, but
that would not be worth the time required to be invested.

>> ___________
>> [1] See <URL:http://en.wikipedia.org/wiki/Trace>, Computing, which you
> often
>>     like to refer to on your Web site.
>
> indeed the first line I read is "The word trace has several meanings" :)

We are talking about applied computer science, do we not?

> with a little advance I wish you an happy new year 2006 PointedEars
> live long and prosper

Thanks, you too.

PointedEars
zwetan - 28 Dec 2005 19:32 GMT
[snip]

> > why should I go all the way to explain in lenghty details
> > the subtle differences between associative arrays and indexed arrays ?
>
> Why should you provide something that returns the names of properties
> of an object when the question was about `var' statements?

because it's useless to obtain the value of a var statement
if you don't know to wich property it is associated...

>   var x, y, z;
>
> should be _one_ entry in the requested list.

That's _your_ coding style

you got other ways of declaring vars
var x;
var y;
var z;

and when you declare variable inside a container
the var keyword is useless

var foobar = new Object();
foobar.x = 0;
foobar.y = 1;

writing "var foobar.x = 0;" is useless
the container "foobar" is already declared with var.

[snip]
> > Why don't you go into those details if you think these explanations are
> > missing and should be stated to undertand better the problem at stake ?
>
> Because it has already been discussed at great length here before.

well instead of pointing my lack of precision concerning that matter
just point a reference to a previous posting discussing it

you think this discussion require such precision so _you_ sould point to the
reference, not me.

> > [...]
> >> > in FF for ex:
[quoted text clipped - 4 lines]
> It does not work this way in Firefox (1.5) without prototype augmentation,
> or in JavaScript for that matter, and it never has.

I didn't tested with FireFox v1.5 yet

And as soon as i will test it for this particular host
I will be able to valid or invalid your comment.

I believe in unit tests not in biased individual with an agenda.

> > you don't need to define the toSource method in  FireFox afaik
>
> True, there is native prototype.toSource() for several core objects but
> it does returns something different than you suggest in all cases.

If you have read what I suggest you would had seen that I suggest
to use an Object object instead of an Array object.

toSource either in native SpiderMoneky implementation or in my own
implementation
does not list array members other than the indexed elements
and this is for me a logic behaviour, if you don't understand why I can
explain it to you.

> > it's natively implemented in the SpiderMonkey engine.
>
> Yes, but it does not do what you suggest.

Yes It does you just didn't pay attention to what I suggest.

> > (and please don't point that I don't provide the exact version of the
> > engine)
>
> It does not and has never worked this way in any SpiderMonkey version.

yes it does, you should test it for yourself instead of being stubborn and
trying to prove at all cost that I have made a false statement.

[snip]

> Usage of exact terms are one important key to understanding.

Yes and you are surely not doing that.

> > I meant "any browser" as "any browser host", as "any browser host
> > implementing ECMA-262 standard",  [...]
>
> It would have been true if you wrote "any language that is an
> ECMAScript _3_ implementation."  What is a "browser host" anyway?

so a host implementing ECMA-262 standard is not an ECMAScript 3
implementation ?

that's really funny to read :)

as far as I know there can be only ECMAScript 3 implementations
as the ECMAScript 4 standard is still as a draft and then not officialy
released...

[snip]

> > and so not being able to execute JavaScript ?
>
> The question conveys a misconception about ECMAScript and JavaScript.
> ECMAScript (3) !== JavaScript (1.5).

I never said that!
you interpreting this yourself thinking you're the only one making the
difference
between ECMAScript (the language as defined in the ECMA-262 3rd edition)
and JavaScript (the implementation of this language in Netscape/Mozilla
browsers).

[snip]

> If you are not able to write Valid markup from the top of your head (which
> is a sure sign of insufficient experience), you should validate the result
> first, because bad examples are copied by the uninitiated and end up in bad
> code.

oh now I understand why you're commenting this way

you're no here to help someone solve a problem or discuss about code

you're here to point that I have "sure sign of insufficient experience"

this is laugthable

are you feeling so insecure about your own experience ?

[snip]
> > I inverted 2 HTML tags..big deal
> > as sometimes I can inverse letters in words too because I write too fast
> > hey I'm just human
>
> The rest of your markup is not Valid, too.

when  you look for a solution it's better to have not a perfect valid code
than no code at all

I think people are smart enougth to grab part of a solution amongs different
comments to write their own solution

there is no problem to point that I inversed some markups,
but the way you do it you only say that to be able to say
that I got "sure sign of insufficient experience",
you don't do that to help solve a problem
you do that to secure your own ego

at best this is childdish from your part

> > What is worhtless imho is someone spending his valuable time
> > pointing finger to all my little errors as if every human were
> > robots and perfect
>
> /You/ _posted_ the example.

You posted no example at all, just unconstructive criticism

if so easy to make no errors when you don't post code at all

> > are we here to help someone solve a problem
> > or to start a fight on what is worthless or not ?
>
> Examples with not Valid markup are worthless, because script code can only
> operate reliably on Valid markup.  That is a fact, not something that can
> or should be fought about.

the fact is that you sound like a kid which have too much time on his hands
to pinpoint all those little things

I never said that unvalid markup was good, it just happen that while
writing those examples I inverted some tags...big deal!

[snip]

> You are misusing the word.  There is nothing traced here at all.  Maybe
> I would have concured if you provided a serialization of the properties,

I don't care if you concur or not, you're obviously not here to have a
constructive debate
about some code or some solution, you're just here to critic whatever you
can critic.

I provide a serialization of the properties, you're just so full of yourself
to not see it.

> that is, show what steps are executed or serialize each known property
> value (including those that are not enumerable) until there would only

you can not serialize properties marked with the dontEnum attribute
go read ECMA-262 3rd edition spec (chapter 8.6.1 , PDF p38/188).

> be primitive values.  That would be some kind of tracing, following the
> trace from one property to the primitive value.  So a trace of
>   x = {y: [/z/]};

the code do provide tracing, but perharps you don't know how to use that
kind of code.

> could look like
>
[quoted text clipped - 17 lines]
>        }
>   };

it's the kind of tracing I got using core2 toSource methods and ToSource
global function
except that the RegExp object is traced as a regular object

[snip...I think you are the issue]
> >> I also see other examples of bad code style:
> >> an undeclared variable just to call a function and then `delete' it,
[quoted text clipped - 12 lines]
> sufficed.  There is no need for the undeclared global variable, hence
> no need for `delete'.

a warning is not an error

my solution is totally valid, and if that does not please you
because you think you know everything and everydy should do as you say
well... :D

avoid falacious arguments like that, it start to really be boring to read
you

> >> bad indentation,
> >
[quoted text clipped - 4 lines]
> No, but that is not the point.  You should and could have stripped it
> better then.

the point is you have no valid argument to tell me how I should
organize, build, etc. my own code

and seeing how you, you organize your own code,
sorry but I prefer to stick on my way of doing things.

I'm still free to do that right ?

> > because their sole purpose are to be used as LIBraries,
> > if you want clean indented code with comments and all
> > you can check the DEVelopper releases,
> > or directly the source code in SVN.
>
> What are you talking about?

you don't read indented code in a compiled DLL right ?

comments, spaces, indentation...these are just to make the code readable by
developpers

the code do not need to be indented to be interpreted correctly
I don't do "readable" libraries I do "compact as possible" libraries
so I repeat, if you want to obtain readable code check the DEV release or
the SVN repository

or perharps you never used the Subversion tool (SVN) ?

> The developer release is just as badly indented:

[snip]

no... really ???

if you think that your coding standard should be imposed to everyone
and that would automagically make all other coding standards "badly
indented"

you think wrong
but you're free to think whatever make you feel comfortable with yourself :)

> >> error-prone property inference and so on.
> >
[quoted text clipped - 7 lines]
> The problem is that you tested with certain host environments and infer
> from those special cases to the general one.

either you're underestimating the amount of work behind my code
or either you try to impose your vision of things on my code requirements

yes I could take the time to try to explain you why things are build like
that in my code,
but I think you would not even read and just try again to impose your point
of view,
so I will save me the trouble and the time of doing that.

> What your code is lacking
> to be almost bullet-proof is a feature-test _on run-time_ that the used
> features, particularly the used DOM features, are supported.

the unit tests are indeed run at runtime ...on each different hosts
the tests does not change depending on the host, they are the same for each
tested host

and I repeat again I don't test DOM features, I test ECMAScript features

trace/printf/document.write are just end points
dependant on the host not on ECMAScript

to include DOM unit tests, that will create errors on host not having a DOM
or force me to have 2 different branching: one for host having a DOM and one
for the other hosts

the goal of the library is to be portable as it is on different hosts either
with a DOM or not
because indeed one of the requirement (and feature) is to have the same API
everywhere.

you are focusing too much on the DOM, and this is totally oppposite to the
requirrement of the code.

> > [...]
> > The merit of a coding style is to be coherent amongs the whole code,
[quoted text clipped - 5 lines]
> misconceptions and often results in unreliable code and/or code
> that is harder to maintain.

oh mister guru please show me the ligth...

as it is now my code have no misconceptions, you can think that
and I can tell you, you're a just plain wrong

I don't claim that my code is perfect but I really start to be tired
of your worhtless comments that I see as personnal attack
just because you got an ego problem

my code is not unreliable because all the code is tested
and yes sure bug can occur, and then I would simply
add more tests concerning that particular bug and the bug will be solved
as any developper would do in any half-serious project...nothing special
here

the code is not harder to maintain
because I use a versioning system,
because I use a build system,
and because I use unit tests

but apparently you can not understand that :)

> I could provide more examples of that right from your code, but
> that would not be worth the time required to be invested.

arf.. no you prefer to invest your time in unconstructive and worthless
criticism
and well I should not be surprised as everybody know: troll do have pointed
ears

first, let me tell you that the example you have already provided are not
valid at all,
second, I highly doubt your capacity of providing such valid examples,
and third, I think my previous respect to your comments was misplaced and
only
occured because of the amount of your posting.

So yes you can post any big volume of criticism,
but as far as I know that does not prove anything about
the validity or invalidity of my code.

If you want to have constructive discussion about ECMAScript programming,
that would be always welcome, if you're only here to impose your point of
view
thinking you are always right about evrything, I'm afraid I will be force to
let you
discuss all that with yourself and just ignore your comments.

zwetan
Thomas 'PointedEars' Lahn - 28 Dec 2005 21:29 GMT
>> > why should I go all the way to explain in lenghty details
>> > the subtle differences between associative arrays and indexed arrays ?
[quoted text clipped - 15 lines]
> var y;
> var z;

Don't be ridiculous.  The request was to return a list of all `var'
statements.  Either is one, so a solution will have to take that into
account.

> and when you declare variable inside a container
> the var keyword is useless
[quoted text clipped - 5 lines]
> writing "var foobar.x = 0;" is useless
> the container "foobar" is already declared with var.

foobar.x and foobar.y are not variables, so they are not "variables
declared inside a container".

> [snip]
>> > Why don't you go into those details if you think these explanations are
[quoted text clipped - 3 lines]
> well instead of pointing my lack of precision concerning that matter
> just point a reference to a previous posting discussing it

It has been more than a handful of postings and threads.  In fact, it is
discussed in almost every other thread because property accessors are a
key feature of the language.

> you think this discussion require such precision so _you_ sould point to
> the reference, not me.

Don't be ridiculous.  Obviously you are the newbie here, so it is _your_
obligation to get informed before you post, not mine to inform you.

However, you may try
<URL:http://groups.google.com/groups?as_q=property+accessor&as_ugroup=comp.lang.javas
cript&scoring=d&filter=0
>
and the like.

>> > [...]
>> >> > in FF for ex:
[quoted text clipped - 5 lines]
>
> I didn't tested with FireFox v1.5 yet

I am sorry, I was about to write "prototype.toString() has never ever
worked in JavaScript the way you suggested, for any core object." when
I recognized you referred to prototype.toSource(), which does work as
suggested in JavaScript.  My bad.

>> > it's natively implemented in the SpiderMonkey engine.
>> Yes, but it does not do what you suggest.
>
> Yes It does you just didn't pay attention to what I suggest.

Not enough, true.  But it appears that I am not the only one here.

>> Usage of exact terms are one important key to understanding.
>
> Yes and you are surely not doing that.

Because I mixed up toSource() with toString()?  You must be kidding.

>> > I meant "any browser" as "any browser host", as "any browser host
>> > implementing ECMA-262 standard",  [...]
[quoted text clipped - 4 lines]
> so a host implementing ECMA-262 standard is not an ECMAScript 3
> implementation ?

Yes, indeed.

> that's really funny to read :)

I am happy that I could amuse you.

> as far as I know there can be only ECMAScript 3 implementations

No, there can be and are ECMAScript Edition 1 implementations, ECMAScript
Edition 2 implementations, and there are scripting languages that resemble
ECMAScript implementations but are none.

> as the ECMAScript 4 standard is still as a draft and then not officialy
> released...

True, I was not referring to ECMAScript Edition 4.

But JFTR: JScript.NET (v7.0) implements ECMAScript Edition 4 features
including class-based inheritance despite its working draft status.
I do not know whether if is possible to use it in IE once .NET 1.0
support is installed.

>> > and so not being able to execute JavaScript ?
>>
>> The question conveys a misconception about ECMAScript and JavaScript.
>> ECMAScript (3) !== JavaScript (1.5).
>
> I never said that!

| is it because of older browsers not implementing fully ECMA-262 3rd
| edition or other browsers not implementing at all ECMA-262 and so not
| being able to execute JavaScript ?

> [snip]
>>
[quoted text clipped - 6 lines]
>
> oh now I understand why you're commenting this way

No, you do not understand at all.

> you're no here to help someone solve a problem

I am, I did and I will do.

> or discuss about code

I am, I did and I will do.

> you're here to point that I have "sure sign of insufficient experience"

Commenting on invalid code and bad code style inevitably includes that.

> this is laugthable

No, it is not, as your examples and your code prove.

> are you feeling so insecure about your own experience ?

That is nothing different than "Do you beat your wife every evening?"
You lose.

> [...]

You are winding around again.

>> > What is worhtless imho is someone spending his valuable time
>> > pointing finger to all my little errors as if every human were
[quoted text clipped - 3 lines]
>
> You posted no example at all, just unconstructive criticism

No, I even pointed out a possible solution to avoid bad code (style).

> if so easy to make no errors when you don't post code at all

Obviously you are not able to learn, let alone to read.
I will not waste any more time with you and your nonsense.

PointedEars
zwetan - 29 Dec 2005 10:11 GMT
[snip]

> Don't be ridiculous.  The request was to return a list of all `var'
> statements.  Either is one, so a solution will have to take that into
> account.

core2 toSource methods and ToSource global fuction  just provide that
solution
I already said that by the way.

[snip]

> foobar.x and foobar.y are not variables, so they are not "variables
> declared inside a container".

a variable member declared inside a container object is called a property
but it's still a variable.

[snip]
> > you think this discussion require such precision so _you_ sould point to
> > the reference, not me.
>
> Don't be ridiculous.  Obviously you are the newbie here, so it is _your_
> obligation to get informed before you post, not mine to inform you.

it's not a problem to be informed or not
it's a problem about you insisting on the first place
that I provide such explanation where it's not required

| > If you want to trace into an associative Array, use an object Object
| > instead
|
| Probably you meant to say "There are no associative Arrays in
JS/ECMAScript.
| What is achieved with associative arrays in other languages, is provided
by
| properties of objects and property accessors here."

here's what you are doing and that I really dislike,
you're focusing so much on showing off your JS culture
that you don't even pay attention to what you are answering

basically I'm just telling to the original poster
instead of declaring the associative array
with an Array object
| var v=new Array();

to use an Object object instead
| var v=new Object();

"associative array" here is not a statement of "yes there are real
associative array in JavaScript",
it's a common and short way to describe one kind of array behaviour amongs
others.

> However, you may try

<URL:http://groups.google.com/groups?as_q=property+accessor&as_ugroup=comp.l
ang.javascript&scoring=d&filter=0>
> and the like.

the original poster did not required such precision
you required them from me

I'm not here to follow your wishes...

you are the one being ridiculous going into that much lengthy commenting
for something the original poster didn't even ask about
and probably already knew

[snip]

> Because I mixed up toSource() with toString()?  You must be kidding.

ok I will quote one of your previous post smart guy

"Usage of exact terms are one important key to understanding."

which I answer

Reading a post, before answering to it, is always a good idea

but you were more applied to critic and surely did not have time to read
what I wrote

> >> > I meant "any browser" as "any browser host", as "any browser host
> >> > implementing ECMA-262 standard",  [...]
[snip]
> > as far as I know there can be only ECMAScript 3 implementations
>
> No, there can be and are ECMAScript Edition 1 implementations, ECMAScript
> Edition 2 implementations, and there are scripting languages that resemble
> ECMAScript implementations but are none.

NO.

I talk about the ECMA-262 standard, there is only one official ECMA-262
standard,
the 3rd one...

again I quote you

"Usage of exact terms are one important key to understanding."

look at
http://www.ecma-international.org/publications/standards/Ecma-262.htm

do you see any ECMA-262 1st or 2nd edition ?

browser implementing only the 1st or 2nd edition of that standard
are either dinosaurs or unsupported and then are irrelevant.

> > as the ECMAScript 4 standard is still as a draft and then not officialy
> > released...
[quoted text clipped - 5 lines]
> I do not know whether if is possible to use it in IE once .NET 1.0
> support is installed.

it's possible but it's kind of a hack as it require FullTrust on the web
client

see:
http://groups.google.com/group/microsoft.public.scripting.jscript/msg/681357247f
c58120?hl=en


and about ES4 (ECMAScript 4) implementation
you can also look for Mozilla Epimetheus, Macromedia ActionScript 2.0,
Macromedia Flex 2 ActionScript 3.0, Mono JScript, DotGNU JScript, etc.

again you asked to use exact terms

"Usage of exact terms are one important key to understanding."

> >> > and so not being able to execute JavaScript ?
> >>
[quoted text clipped - 6 lines]
> | edition or other browsers not implementing at all ECMA-262 and so not
> | being able to execute JavaScript ?

a browser implementing the ECMA-262 standard
allow the browser to execute JavaScript code

not all browsers execute JavaScript 1.5 based on the SpiderMonkey engine

Internet Explorer use its own JScript engine
Safari have forked the Konqueror KJS engine
etc.

[snip]

> No, I even pointed out a possible solution to avoid bad code (style).

no you didn't

you got your own conception of bad code style
and even if you are a longtime poster here
that does not mean your coding style is the only one
universaly being "good".

> > if so easy to make no errors when you don't post code at all
>
> Obviously you are not able to learn, let alone to read.
> I will not waste any more time with you and your nonsense.

here a french citation for you
"La culture c'est comme la confiture, moins on en a plus on l'étale."
(Pierre Desproges)

which could be translated to
"culture is like jam, the less one has the more it is spread out."

you created all that nonsense, not me

zwetan
Thomas 'PointedEars' Lahn - 29 Dec 2005 15:01 GMT
>> Don't be ridiculous.  The request was to return a list of all `var'
>> statements.  Either is one, so a solution will have to take that into
>> account.
>
> core2 toSource methods and ToSource global fuction  just provide that
> solution

They appear to provide but a list where each element is an enumerable
property of an object, which is a completely different thing.

From "core2 v1.0.0.66 DEV for Browsers JavaScript",
release/dev/core2_v1.0.0_JS/buRRRn/core2/Object.js:269:

/* Method: toSource
  Returns a string representing the source code of the object.
  Parameters:
  indent   - optionnal, the starting amount of indenting
  indentor - optionnal, the string value used to do the indentation
*/
Object.prototype.toSource = function( /*int*/ indent, /*String*/ indentor )
   {
   var member, source;
   source = [];
   if( indent != null )
       {
       indent++;
       }
   for( member in this )
       {
       if( this.hasOwnProperty( member ) )
           {
           if( this[member] === undefined )
               {
               source.push( member + ":" + "undefined" );
               continue;
               }
           if( this[member] === null )
               {
               source.push( member + ":" + "null" );
               continue;
               }
           source.push( member + ":" + this[member].toSource( indent,
indentor ) );
           }
       }
   if( indent == null )
       {
       return( "{" + source.join( "," ) + "}" );
       }
   if( indentor == null )
       {
       indentor = "    ";
       }
   if(indent == null )
       {
       indent = 0;
       }
   var decal = "\n" + Array.initialize( indent, indentor ).join( "" );
   return( decal + "{" + decal + source.join( "," + decal ) + decal +
"}" );
   }

From release/dev/core2_v1.0.0_JS/buRRRn/core2/_global.js:294:

/* GlobalFunction: ToSource
  Allow you to dump the source of the Global Object scope.
  example:
  (code)
  trace( ToSource( 0 ) );
  (end)
  see: <Object.toSource>
*/
_global.ToSource = function( /*int*/ indent, /*String*/ indentor )
   {
   var target, member, source;
   source = [];
   if( indent != null )
       {
       indent++;
       }
   for( member in _global )
       {
       if( isGlobalReserved( mm ) )
           {
           continue;
           }
       if( member == "__path__" )
           {
           continue;
           }
       if( _global.hasOwnProperty( member ) )
           {
           if( _global[member] === undefined )
               {
               source.push( member + ":" + "undefined" );
               continue;
               }
           if( _global[member] === null )
               {
               source.push( member + ":" + "null" );
               continue;
               }
           source.push( member + ":" + _global[member].toSource( indent,
indentor ) );
           }
       }
   if( indent == null )
       {
       return( "{" + source.join( "," ) + "}" );
       }
   if( indentor == null )
       {
       indentor = "    ";
       }
   if(indent == null )
       {
       indent = 0;
       }
   var decal = "\n" + Array.initialize( indent, indentor ).join( "" );
   return( decal + "{" + decal + source.join( "," + decal ) + decal +
"}" );
   }

(So much for your claim of proper indentation in the "developer sources" and
for your claim that using the Comma operator in `var' statements would be
but my coding style.)

Unfortunately, it is impossible to test that it does what you claim it would
do, because

| Error: mm is not defined
| Source file:
| file:///tmp/core2/release/dev/core2_v1.0.0_JS/buRRRn/core2/_global.js
| Line: 312

(|Warning: assignment to undeclared variable _introspectGlobal
| Source file:
| file:///tmp/core2/release/dev/core2_v1.0.0_JS/buRRRn/core2.js
| Line: 21)

with

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
 "http://www.w3.org/TR/html4/strict.dtd">
<html>
 <head>
   <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
   <title>core2 Test</title>
   <script src="release/dev/core2_v1.0.0_JS/buRRRn/core2.js"
     type="text/javascript"></script>
   <script src="release/dev/core2_v1.0.0_JS/buRRRn/core2/_global.js"
     type="text/javascript"></script>
   <script type="text/javascript">
     var x, y, z;

     function _onload()
     {
       trace( ToSource( 0 ) );
     }
   </script>
 </head>

 <body onload="_onload();">
   <div id="TraceConsole"></div>
 </body>
</html>

on

Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8) Gecko/20051224
Debian/1.5.dfsg-3 Firefox/1.5 Mnenhy/0.7.3.0

and there is no occurence of the word `mm' in the rest of the files that
would declare that variable.  Maybe you can explain what I did wrong.

> I already said that by the way.

Yes, you talk much.

>> foobar.x and foobar.y are not variables, so they are not "variables
>> declared inside a container".
>
> a variable member declared inside a container object is called a property
> but it's still a variable.

Utter nonsense.  Read ECMAScript Edition 3, especially subsection 10.1.3.

It also talks volumes that your HTML documentation of the project refers to
prototype objects as "Classes".  Why am I not surprised?

<URL:http://www.burrrn.com/documentation/core2/index/Classes.html>

So much for your understanding of the programming language(s) used.

PointedEars
zwetan - 30 Dec 2005 03:08 GMT
> >> Don't be ridiculous.  The request was to return a list of all `var'
> >> statements.  Either is one, so a solution will have to take that into
[quoted text clipped - 5 lines]
> They appear to provide but a list where each element is an enumerable
> property of an object, which is a completely different thing.

humm ok you say it's completely different thing
can you provide a scenario of what you would expect ?

like: I got this code, if I trace this reference of code I would expect this
result, not that result.

toSource has been heavyly inspired by the SpiderMoneky engine toSource
functionality
but it can not be exactely the same as we are implementing it from
client-side source code
not directly in the host engine.

some limitations:
- impossibility to trace member marked as "DontEnum"
- no assignement of pointers to represent circular reference

some differences:
- choice to not trace the body of Function object
- choice to not implement toSource for REgEx object

> From "core2 v1.0.0.66 DEV for Browsers JavaScript",
> release/dev/core2_v1.0.0_JS/buRRRn/core2/Object.js:269:

[snip]

notice that to have full tracing you need all core object "toSource"
implementation
not only the Object.prototype.toSource

this is implemented as a polymprophic behaviour,
each core object having its own implementation of toSource

if you don't include the Array, Boolean, etc. toSource implementation
sure it could not work as expected.

> From release/dev/core2_v1.0.0_JS/buRRRn/core2/_global.js:294:

[snip]

> (So much for your claim of proper indentation in the "developer sources" and
> for your claim that using the Comma operator in `var' statements would be
> but my coding style.)

for me the source code is properly indented, and as specified in
http://live.burrrn.com/wiki/CodingStandard
" As a general rule the coding standard to follow is the coding style of the
module owner. "

I will not impose my coding style to your code
and I expect you don't impose me your coding style in my code

I will not change the indentation of 30Kloc+ source code to please you.

see also
http://wiki.mozilla.org/Update:Development:Best_Practices
" Coding standards should be chosen, not argued about. "

perharps you experiencing problems in indentation because
of the difference of CR/LF between Windows and Linux ?

> Unfortunately, it is impossible to test that it does what you claim it would
> do, because
[quoted text clipped - 3 lines]
> | file:///tmp/core2/release/dev/core2_v1.0.0_JS/buRRRn/core2/_global.js
> | Line: 312

yes that's a bug, referenced here
http://live.burrrn.com/ticket/14

a stupid bug that happened after the refactoring of some local variable

note that this bug is not patched yet because there are also some
refactoring going on
in the global ToSource function and also the GetObjectPath global function
which would add the little feature to be able to introspect  core objects in
a better way

core2 v1.0.1 (planed for 2006/01/02) will solve all that
as a quick fix you can just replace "mm" local variable by "member".

> (|Warning: assignment to undeclared variable _introspectGlobal
>  | Source file:
>  | file:///tmp/core2/release/dev/core2_v1.0.0_JS/buRRRn/core2.js
>  | Line: 21)

the ECMAScript host where this code has been tested that you can see listed
here
http://www.burrrn.com/projects/core2.html
do not yeld such a warning

in brief, if the host where you're running the code is not included in the
tested hosts
sure some warning could be yeld, it just a matter of adding those hosts to
the test cycle.

> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
>   "http://www.w3.org/TR/html4/strict.dtd">
[quoted text clipped - 6 lines]
>     <script src="release/dev/core2_v1.0.0_JS/buRRRn/core2/_global.js"
>       type="text/javascript"></script>

stop here

that's why there is a DEV release and a LIB release

to save you trouble to include dozens of script files
you would be better using the library as 1 single file

<script src="release/lib/core2_v1.0.0_JS.js"
type="text/javascript"></script>

you can not just include part of the library, you have to include all the
files.

>     <script type="text/javascript">
>       var x, y, z;
[quoted text clipped - 10 lines]
>   </body>
> </html>

as you are including only parts of the core2 library
it surely does not work

core2 is about augmenting all the ECMAScript core objects,
this create a dependency on core2 itself,
it's all or nothing, you can not pick part of the core2 library.

This is a design choice, we stick to the objects we avoid global function,
it got its pros and cons, one of the pros is that it allow a lot of code
reuse,
one of the cons is that it force you to include all the files.

> on
>
> Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8) Gecko/20051224
> Debian/1.5.dfsg-3 Firefox/1.5 Mnenhy/0.7.3.0

ok, I can not test on Linux, but your case interest me
as the goal is to be able to run in any hosts and in particular any OS

I will add tests using Firefox v1.5 on windows
hoping that the windows version have a similar behaviour than the linux
version

this is an evolving project, the main part is stable (hence the versioning
1.0.0)
but there still could have some bugs or glitch that can be improved.

When core2 v1.0.0 was released Firefox v1.5 was still in beta for exemple.

> and there is no occurence of the word `mm' in the rest of the files that
> would declare that variable.  Maybe you can explain what I did wrong.

except including just "_global.js" and "Object.js", you did nothing wrong

the "mm" local variable is a bug that I did not catch in time,
it will be solved for the core2 v1.0.1 release

[snip]

> It also talks volumes that your HTML documentation of the project refers to
> prototype objects as "Classes".  Why am I not surprised?
>
> <URL:http://www.burrrn.com/documentation/core2/index/Classes.html>
>
> So much for your understanding of the programming language(s) used.

first I use a 3rd party tool to generate the documentation: NaturalDoc
this tool is really good, but as it generate documentation not only for
ECMAScript languages
it uses common term used by other languages,
this tool use the term "class",
if you want to know my point of view concerning a good naming in ECMAScript
you can read that post here
http://www.zwetan.com/blog/ECMAScript/RaisingHell.html
"The main idea being that a prototype-based language allows to create object
without class, and that's why imho you can not use the class terminology
inside ECMAScript."

You will also notice that in my inline code comments I never use the terme
"class"
but the term "constructor" which is imho a better term to classify an
ECMAScript pseudo-class.
see for exemple
http://live.burrrn.com/browser/ECMA-262/core2/trunk/src/buRRRn/core2/NullObject.es

/* Constructor: NullObject
  Utilitarian object allowing to treat
  a null value as an object.

  note:
  usefull for some polymorphic situation.

  see: <http://c2.com/cgi/wiki?NullObject>
*/
_global.NullObject = function()
{

}

zwetan
Thomas 'PointedEars' Lahn - 30 Dec 2005 06:21 GMT
>> >> Don't be ridiculous.  The request was to return a list of all `var'
>> >> statements.  Either is one, so a solution will have to take that into
[quoted text clipped - 6 lines]
>
> humm ok you say it's completely different thing

Yes, indeed.  Declared variables are properties of the Variable Object of
the execution context (ES3, 10.1.3), that is the Global Object in global
context.  But not all properties are variables.

One simple example that makes this difference clear: the `delete' operator
(ES3, 11.4.1) can be applied to declared (that is, user-defined) variables
but it has no effect because those variables, or properties of the Variable
Object, have the DontDelete flag set during variable instantiation (ES3,
10.2 and 8.6.2.5).  The `delete' operator can be applied to user-defined
properties of objects different from the Variable Object and always has
effect because those properties have _not_ been subject to variable
instantiation; they are _not_ variables.

> can you provide a scenario of what you would expect ?
>
> like: I got this code, if I trace this reference of code I would expect
> this result, not that result.

 function x()
 {
   var y = 23, z;
 }
 x.foo = 42;

A solution returning a list of the variables declared in the local context
of x() should return a list with the elements `y' and `z' (and maybe a
representation of their assigned value).  A solution returning a list of
`var' statements in the local context of x() should return a list with
the only element

 var y = 23, z;

A solution returning the enumerable properties of the Function object `x'
refers to (short: x) should at least return `foo', but not `y' or `z',
because the latter ones are properties of the Variable Object created when
the method is called and the local context is entered, not properties of x.

> some limitations:
> - impossibility to trace member marked as "DontEnum"

It is possible to "trace" known properties that have the DontEnum flag.
My ObjectInspector[1] does a pretty good job at that.

> - no assignement of pointers to represent circular reference

I am not sure what you mean by that.

It is possible to determine that a property value is a reference
to the property owner.  My ObjectInspector can do that.

[1]
<URL:http://pointedears.de/scripts/test/ObjectInspector/nightly/latest/index>

> some differences:
> - choice to not trace the body of Function object

So your library will _never_ be able to provide the solution the OP asked
for.  In case you forgot: that was a list of all _`var' statements_.

> - choice to not implement toSource for REgEx object

That is /your/ decision (one that I would not follow) and /your/ problem.

> [...]
>> From "core2 v1.0.0.66 DEV for Browsers JavaScript",
[quoted text clipped - 11 lines]
> if you don't include the Array, Boolean, etc. toSource implementation
> sure it could not work as expected.

OMG.  Are you telling me I have to include the whole Array.js for

| _global.ToSource = function( /*int*/ indent, /*String*/ indentor )
|   {
[quoted text clipped - 3 lines]
| );
|   }

which does nothing more than this?

| Array.initialize = function( /*int*/ index, value )
|     {
[quoted text clipped - 3 lines]
|         }
|     if( value === undefined )
                   ^^^^^^^^^
|         {
|         value = null;
[quoted text clipped - 7 lines]
|     return arr;
|     }

BTW: This will break in IE before version 5.5 (as it was introduced
in JScript 5.5).  typeof value == "undefined" will not break in any
current or previous IE version that is still of any use (as the
operator was in