Bart said:
Richard said:
[...]
You appear to be confusing javascript with C or some other language.
I'm not talking about javascript code. I'm talking about how
a browser compiles javascript code.
Browsers are not the only software that executes javascript code, and
you don't know how it is done in 'a browser', or anywhere else, in
general. You can only examine how it is done in specific
implementations, and cannot validly generalise beyond that. When you
are thinking about this remember that there is at least one javascript
implementation written in javascript.
Indeed, not at the high javascript code level - but it does at the
browser's low compile level.
Not necessarily. IceBrowser uses Rhino for its javascript engine, and
Rhino is written in Java, so has no pointers. If you insist on going
down through the layers you will end up at the machine code level,
where there are no 'pointers', only integers loaded into data and
address registers, etc.
These are just general basic computer
mechanisms. Every variable points (or 'references' if you like) to a
memory block address.
A memory address, it is only conceptually a block when some (byte)
length information is also associated with the value.
That isn't visible at the surface in javascript,
but is definitely how it works internally.
Which may be no more useful a statement than observing that CPUs
execute machine code.
Referencing and memory allocation take place when the
browser compiles the javascript to
something the machine understands.
Rhino does not compile javascript to something the machine understands,
it compiles it to something the JVM understands, and the JVM does the
next step.
That's why it's so difficult to
influence memory handling from within javascript.
The difficulty is because javascript uses automatic garbage collection,
which is not intended to be influenced by executing code.
No, 'null' is a well defined address (must be)
No, in javascript Null (the value that is assigned with - x = null -)
is a primitive value, and may or may not have any association with a
memory address.
and its reference is
somewhere between 0x000 and 0x0000000000000
An address between zero and zero (not a very wide gap)?
(BTW, null is not a value,
it's the "not-value" that is defined that way by 0x0...).
Not in javascript. In javascript Null is a primitive type with a single
value. The nature of that value is not specified or important. It may
be entirely arbitrary, or borrowed from the implementation language.
Any computer language works with memory allocation/release
and (de)referencing to those.
Memory allocation is not part of machine code. The lowest level at
which memory allocation would be expected is at the level of the OS.
And once you get far enough up that the memory allocation has been
abstracted outside of your control it stops being part of the picture
again.
Oh yes you are. You just don't have access to the information necessary
to make these generalisations.
You're right - this discussion is irrelevant to javascript authoring
itself.
So irrelevant to this group.
Richard.