Re: This (Javascript) function has an onClick event that calls a function that calls This function



In message <453f0c51$0$323$e4fe514c@xxxxxxxxxxxxxx>, Wed, 25 Oct 2006 08:54:28, Maarten Wiltink <maarten@xxxxxxxxxxxxxxxxxx> writes
"Dr J R Stockton" <jrs@xxxxxxxxxxxxxxxxxx> wrote in message
news:IhwFb5F8$kPFFw0N@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
In message <453dcb16$0$338$e4fe514c@xxxxxxxxxxxxxx>, Tue, 24 Oct 2006
10:13:07, Maarten Wiltink <maarten@xxxxxxxxxxxxxxxxxx> writes

[Javascript] Functions are not resolved ahead of
time, but only when they're actually called. At that time, the entire
source is scanned, so forward declarations aren't necessary.

I agree with the second half of your last sentence, but not with the
first half (that would be intolerably slow).
[...]
the names and addresses of the functions will be put in a list during
a pre-execution scan; during execution, it is only necessary to seek
within the list (which can be done more or less efficiently).

Would you believe that I deleted some extra lines from that paragraph
where I was going to say that this _behaviour_ did not preclude a
compiled _implementation_?

I can believe the deletion. But ISTM that it would be very difficult to fulfil the language specification by compilation to machine code or anything like it. The pre-execution scan referred to is not a compilation; it is initialisation of a data/code structure.

The effect is that the entire source is scanned. How this effect is
obtained is irrelevant except for performance considerations. The
scanning might be postponed until necessary; then the source _would_
be scanned the first time an unknown function was encountered.

Might be postponed in principle; will not be in practice. Javascript cannot match Delphi in performance; but the implementors will have by now gone for all the efficiency that the language permits.

It's a good idea to read news:comp.lang.javascript and its FAQ. See below.

--
(c) John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v6.05 IE 6
<URL:http://www.jibbering.com/faq/>? JL/RC: FAQ of news:comp.lang.javascript
<URL:http://www.merlyn.demon.co.uk/js-index.htm> jscr maths, dates, sources.
<URL:http://www.merlyn.demon.co.uk/> TP/BP/Delphi/jscr/&c, FAQ items, links.
.