On Mon, May 31, 2010 at 8:09 PM, Giacecco <[email protected]> wrote:

> ... but what I am doing lately is writing standalone .js files, to be
> run with V8 from a shell. What can I do to organise my code in more
> files and include it as necessary, if I can't use the above?
>

The command is called "load()" in the demo shell.


> Is this perhaps a limitation of ECMAscript, which was not intended to
> run but within a web page?
>

It's a limitation that the language defines no mechanism for i/o (amongst
other things it leaves out), and loading anything at all requires i/o. The
core language doesn't (AFAIK) specify anything to do with HTTP/HTML (like
the SCRIPT tag), either - those are part of DOM API, if i'm not mistaken.
You cannot use the DOM API (e.g. the SCRIPT tag or setTimeout()) from the
shell - it only supports the core JS language. You can of course write your
own functionality (e.g. a setTimeout() function) and add it to the shell,
but by default it only supports language-specified constructs plus the
semi-conventional load() and print() extensions. (i think most shells call
load() include(), though.)

The only book i'm aware of which clearly distinguished between the core and
DOM APIs is O'Reilly's "JavaScript: the Definitive Guide" (and it's the only
JS reference you'll ever need).

-- 
----- stephan beal
http://wanderinghorse.net/home/stephan/

-- 
v8-users mailing list
[email protected]
http://groups.google.com/group/v8-users

Reply via email to