> JavaScript needs a standard way to include other modules and for
> those modules to live in discreet namespaces. There are easy ways
> to do namespaces, but there's no standard programmatic way to load
> a module (once!). This is really important, because server side apps
> can include a lot of code and will likely mix and match parts that
> meet those standard interfaces.
An include/load/require system is the essential ingredient in
developing an extensible core interpreter. If a standard existed for
how modules load, then more code could be shared.
Unfortunately, people disagree about how this should be done. Some
like the shared global scope with a module in each child scope and/or
namespace is the way to go. I think this is unnecessarily complex and
that a single global scope like the browser has is the way to go and
anything more should come from the language first.
A large discussion about these issues was had on the Helma NG group
with three main participants. The lack of agreement on the module
system issue was a complete spoiler. I believe this is *the* major
issue to overcome.
Peter
Do you have a pointer to it? That way we could read up beforehand and
avoid going through the same issues :)
--
Robin Berjon
Robineko (http://robineko.com/)
This is not the difference folks usually mean when they talk about
namespaces and module loading systems. What you are showing is
simulating namespaces by using an object hierarchy in a global
namespace system. It works in the browser and would work fine in a
server-side system with a global namespace. I'm in favor of this type
of system (though see ssjs_file_open as better than ssjs.file.open in
several ways). These types of namespacing strategies are based on
convention.
When folks talk about "real" namespaces they are usually meaning
systems where code from one namespace has a limited, controlled
channel of interaction with objects from another namespace. There is
language or host support to assist or support the idea of namespaces.
From what I've seen on the ECMAScript mailing list, this sort of
system has been proposed and rejected (at least for now) from
ECMAScript.
Peter
> 3) Some command line JS interpreters already come with a File object,
> but they all vary slightly in how they work. Hopefully this project
> will standardize them, not augment them. Having "File" and "ssjs.File"
> is just confusing.
I don't agree there. Python does that because there's only one Python
interpreter. (Well, there are others, but they're explicitly
compatible with CPython.) We have multiple incompatible interpreters.
If there's going to be a global File object then we either wait for
all the interpreters to implement it, or we implement it ourselves as
a wrapper on top of whichever interpreter you're on. As you say, some
interpreters already come with a File object, but the whole point of
standardising an API, to my mind, is to make sure you can write SSJS
to one API and not many. If you're using ssjs.File then you *know*
that it's the standard file object. If you're using File, then you
don't know whether it's the SSJS file object or the interpreter's file
object. Worse, if we override an existing global File with our global
File then anyone who *wants* to make their project
interpreter-dependent is out of luck, because we've overridden the
interpreter's API.
> 4) If you force all 3rd party libraries loaded through the package
> system to also be part of this "ssjs" namespace, you're not fixing the
> collision problem, you're just moving it down one layer.
I don't think that's a good idea (it's certainly not what I'm
proposing). SSJS would be the anointed, simple, API that does the
basics. Other libraries can depend on it if they want to, but I don't
think that they're part of it.
sil
Your argument relies entirely on clashes with identically named
objects in existing interpreters. I agree that that can be a problem —
if, say, you redefine File.open() then anything that already relies on
it in that implementation might break — but disagree that stuffing
everything into a subnamespace is necessarily the solution: we can
simply pick names that don't clash with the implementations that we're
targeting.
So, I strongly opt for [global].File() instead of ssjs.File().
Ondrej
Those are two separate issues. The standard stuff defines a (limited)
number of objects in the global namespace (e.g. File) and then
extensions do whatever they want, except that good practice is
documented telling people not to pollute the global namespace. That's
how CPAN works, and overall it works really well.
Since this group is essentially a specification group, that is just a
matter of specifying only one API.
> Many of the things we're planning on doing will require modifying the
> command line shells themselves. In the process I don't have any qualms
> about replacing an old File object API with the new standard one.
>
> But now that I think about it, none of the standard shells actually
> come with a File object. So neither of our arguments on that one are
> valid ;)
Command shells are applications (just like browsers are) where the
application has a JavaScript interpreter embedded inside the
application.
> - Rhino has java.io.File, of course. No namespace conflict there though.
> - SpiderMonkey/TraceMonkey has one that's not included in normal
> distributions, and they don't sound very enthusiastic about it: https://developer.mozilla.org/En/SpiderMonkey/File_object
> - V8 doesn't have one (lv8call and v8cgi implement incompatible ones)
> - JavaScriptCore doesn't have one.
It is the host application's job to expose access to things
appropriate to the particular scripting environment. A server-side
interpreter can expose a File object. A browser interpreter should
not. So it is good that SpiderMonkey and V8 don't expose File as a
standard host object.
> Those are the "big four" in my mind. What others are there that we
> want to support?
This discussion group won't support JavaScript implementations. Host
applications will choose to support the results of this discussion
group by adding host objects and only if a particular host application
finds doing so worthwhile and beneficial.
Peter
Although a standard File API would be great, the actual File
implementation can be as an extension itself. The only thing that
needs to be added to the JavaScript interpreter is something like
"load" to execute other files of code. One of those files of code
could contain a File object.
> do whatever they want, except that good practice is
> documented telling people not to pollute the global namespace. That's
> how CPAN works, and overall it works really well.
I agree. A library author should not be forced into a straight jacket.
He should be shown how to put on the straight jacket himself. I think
most JavaScript programmers realize a library global function called
"trim" has a good chance of namespace collision and would like to
avoid that.
Peter
I mostly agree and would like to agree completely.
I think that CPAN offers a good example to follow. Because CPAN is the
canonical repository, code in CPAN can define a global like "File".
The CPAN maintainers approve new namespaces to avoid collision. If
everyone else in the Perl world uses a prefix containing who they are
then that will never collide with CPAN naming because CPAN naming
doesn't contain any information about who is writing the code. So a
company called XYZ would write an XYZ::File module and that would
likely never collide with any CPAN module because "XYZ" is a company
name and likely not appropriate for a CPAN module. There is still some
risk.
Java takes this to what might be considered an extreme by using
reverse domain names. That same company's class would be com.xyz.File
and this naming convention almost ensures no collisions as domains are
registered with a central service.
For a standardized JavaScript file object, if the desired semantics
are a global file object then it is a matter of choosing a string for
that object's identifier. Choosing "File" would work. Choosing
"std_File" would work. Even "asdf" would work. Some of these are
better than others but they all have the same semantics.
Peter
>
> On Fri, Jan 30, 2009 at 5:11 AM, Thomas Robinson
> <tlrob...@gmail.com> wrote:
>>
>> I think the concept of wrapping a bunch of existing incompatible APIs
>> in a library is a necessary evil of the browser world, which we
>> should
>> try to avoid on the server, because we can.
>
> Since this group is essentially a specification group, that is just a
> matter of specifying only one API.
>
>> Many of the things we're planning on doing will require modifying the
>> command line shells themselves. In the process I don't have any
>> qualms
>> about replacing an old File object API with the new standard one.
>>
>> But now that I think about it, none of the standard shells actually
>> come with a File object. So neither of our arguments on that one are
>> valid ;)
>
> Command shells are applications (just like browsers are) where the
> application has a JavaScript interpreter embedded inside the
> application.
Yes, but the interpreter doesn't implement the File object, otherwise
we would all have File objects in the browser. The shell, or some
library included by the shell, implements it.
>
>> - Rhino has java.io.File, of course. No namespace conflict there
>> though.
>> - SpiderMonkey/TraceMonkey has one that's not included in normal
>> distributions, and they don't sound very enthusiastic about it: https://developer.mozilla.org/En/SpiderMonkey/File_object
>> - V8 doesn't have one (lv8call and v8cgi implement incompatible ones)
>> - JavaScriptCore doesn't have one.
>
> It is the host application's job to expose access to things
> appropriate to the particular scripting environment. A server-side
> interpreter can expose a File object. A browser interpreter should
> not. So it is good that SpiderMonkey and V8 don't expose File as a
> standard host object.
>
>> Those are the "big four" in my mind. What others are there that we
>> want to support?
>
> This discussion group won't support JavaScript implementations. Host
> applications will choose to support the results of this discussion
> group by adding host objects and only if a particular host application
> finds doing so worthwhile and beneficial.
That's ideally how it would work, but I suspect if we just release a
spec and hope for the JS engine developers to implement it themselves
it will take years. I think we'll need to actively develop at least
one "reference implementation" of the spec.
But if there are JS engine contributors here who plan to support this
project, it would be nice to hear that :)
I saw Norris Boyd (creator of Rhino) is on the list, but I don't know
if he or anyone from the Rhino project plans to actively implement
this stuff.
> With Helma NG, you have full control how you want to access your
> modules. import('helma.file') will put the module into a helma.file
> namespace,
Does that mean global.helma.file will access the file object from any
code (previously loaded or loaded later)?
What is the general structure of the helma.file code? Something like this
var helma = helma || {};
helma.file = function() {
// ...
}
//... helma.file and helma.file.prototype properties
> while include('helma.file') will set up the File
> constructor (generally all exported symbols) directly in your local
> scope, and you can do var file = require('helma.file') to take control
> of the namespace yourself.
> I personally wouldn't want to live without
> this, just like no Python person in one's right mind would trade
> python's module system for something less flexible.
I'm not sure anything conclusion can be drawn from this statement.
Presumably a Python person choose Python because he likes how Python
works. That implies he wouldn't want to change how Python works.
Peter
To be precise, that's not actually the case. PAUSE users (PAUSE is the
name of the system to upload to the CPAN) can upload modules that
contain namespaces *so long as those namespaces are not already in
existence*. Basically, it's a first-come-first-serve system. If the
name already exists, then you need maintainer or co-maintainer status
on that namespace to upload (the status can be granted to you by
whoever owns it). There is an approved list of modules (the registered
modules) that CPAN admins maintain but that's largely fallen into
disuse because the first-come-first-serve approach (perhaps
surprisingly) works very well on its own.
>
> It could behave something like this:
>
> import("File")
> Import the standard File object directly into the global namespace. So
> now you can do
> var f = new File("some.txt");
> var lines = f.readLines();
> or
> var lines = File.readLines("some.txt");
>
> Maybe import could have an optional second argument, which object to
> insert into:
> var myObj = {};
> import("File", myObj)
> var f = new myObj.File("some.txt");
> var lines = f.readLines();
> or
> var lines = myObj.File.readLines("some.txt");
In my playing with "modules" in JS, what I've done is had the import()
function return a "module" object which had properties that the module
exported. So the code might look something like this:
var IO = import("io.jsm")
var f = new IO.File("some.txt")
...
In this case, there's an "io" module, which exports a class named
"File". What's interesting about this is the "global naming" problem
goes away, kind of. The only global names are the module names
(presumably uri's of some kind). Within each module, the namespace is
managed by the module.
Patrick Mueller
http://muellerware.org/
You really don't want that. Libraries want to work everywhere
irrespective of the environment, so the second you introduce that
option, every library that needs to import something will do if
(import) import(Foo) else SSJS.import(Foo). Or if SSJS is always
present, then people will just use that, making the option useless. It
becomes a mess :)
Introducing a small, controlled number of globals is fine. You might
not want to make actual functions global but rather objects so that
new functionality can go on said objects rather than in the global
namespace. Random example: if in v2 we want to have unimport()
(matching Perl's "no" keyword) we're better off with Module.import()/
Module.unimport() than with adding unimport() globally.
It would really be nice to get away from a 'File' object (which, to
me, means a filesystem directory or file) and go to Collection and
Resource (or Document or Doc). Then it would be up to the implementor
to abstract away and/or mix a filesystem, a json DB (at least like
mongodb as couchdb doesn't have collections... don't know much about
perservere), an XML db or a relation db.
I also think a RESTful perspective would be very useful in dealing
with Collections and Resources.
best,
-Rob
I like Python's system of modules very much as well...
But, I'd like to make a suggestion that may help this thread from
continuing endlessly. I think that's especially important because
*everything* will be built on how modules work.
My suggestion is that people who are interested or already have useful
APIs for this or whatever, create a new page under ServerJS/Modules/
quickly describing the approach (basically a few examples of file
layout and inclusion of modules). If you've already got some docs, you
can copy and paste that in or something. And then add a link under
"Proposed API" here:
https://developer.mozilla.org/ServerJS/Modules
It's hard to have productive conversations about APIs without code to
look at. Once there's a somewhat complete picture, it's much easier to
spot and discuss strengths and weaknesses.
Kevin
--
Kevin Dangoor
email: k...@blazingthings.com
blog: http://www.BlueSkyOnMars.com
> I'd also mention that it sounds like some of the proposals would
> require you to write files which would be imported in a certain way.
This is why the module system is such an important issue.
> Maybe I'm just misunderstanding, but I think that's definitely
> something that needs to be avoided.
In some sense, it cannot really be avoided. Any choice on script
loading mechanism will impact the way scripts are written.
> I should be able to import any file containing valid javascript and
> have it be available to me just as if I had included it with a
> <script> tag in the browser.
I agree for the simple reasons that it is how things work in the
browser and people already know how that works in JavaScript. By
writing files essentially the same way they are written for the
browser, it means server-side code can easily be shared with the
browser.
Peter
> In some sense, it cannot really be avoided. Any choice on script
> loading mechanism will impact the way scripts are written.
>
>> I should be able to import any file containing valid javascript and
>> have it be available to me just as if I had included it with a
>> <script> tag in the browser.
>
> I agree for the simple reasons that it is how things work in the
> browser and people already know how that works in JavaScript. By
> writing files essentially the same way they are written for the
> browser, it means server-side code can easily be shared with the
> browser.
Maybe we just disagree on terminology here. But I agree, you should be
writing javascript files exactly the same way you already do for the
browser. This is what I meant by not requiring a specific syntax for
allowing import of a file.
The fact that JavaScript left out this feature is unfortunate, but
there are already plenty existing implementations out there in the
wild. Dojo has one, Objective-J has one, Jack has one, and they all
work differently.
It would probably be a good idea to survey what people are doing, and
either just pick an existing implementation or create a new compromise
solution that makes everyone reasonably happy.
> Maybe we just disagree on terminology here. But I agree, you should be
> writing javascript files exactly the same way you already do for the
> browser. This is what I meant by not requiring a specific syntax for
> allowing import of a file.
The problem is, "the way you do for the browser" means you have to
write assuming your code gets run in the "global context". Some of
the module stories have a different way of working, like loading your
code into a new context. It sounded like one already mentioned here
(Helma?) supports BOTH. You can include() a resource, which is just
like <script src=""> (or #include in C) but they also had an import()
which was more like a Python import. Actually, supporting both would
be nice, include() for pre-existing stuff, or those times when you
really do want stuff imported into the global namespace, and import()
for libraries where you'd like to take advantage of the new context.
The problem is, you probably need to know which one to use for a
particular module, and using the wrong one is going to give you
surprises.
> The fact that JavaScript left out this feature is unfortunate, but
> there are already plenty existing implementations out there in the
> wild. Dojo has one, Objective-J has one, Jack has one, and they all
> work differently.
I'd say it's a blessing, to some extent. It doesn't need to be added
to the language (if that's the suggestion), since it can be added as
new function. Letting folks experiment with different ways of doing
this. Same is true for people who want to add "classical OO" type
capabilities - you can do it via functions, without having to have new
language constructs, though the resulting function invocation may look
a bit messier. This, BTW, is the same approach Smalltalk took - there
are no "language level" features to define classes, defining classes
is done via message sends.
Patrick Mueller
http://muellerware.org/
> My suggestion is that people who are interested or already have useful
> APIs for this or whatever, create a new page under ServerJS/Modules/
> quickly describing the approach (basically a few examples of file
> layout and inclusion of modules). If you've already got some docs, you
> can copy and paste that in or something. And then add a link under
> "Proposed API" here:
>
> https://developer.mozilla.org/ServerJS/Modules
Two ideas posted.
Peter
Writing a send function
send(obj, "message", arg0, arg1);
or making objects functions of their messages
obj("message", arg0, arg1);
or using multi-methods
message(obj, arg0, arg1)
all work. They are instant ways to free the programmer from the
limited, built-in OOP system. They are all slower than the built-in
style as dispatch cannot be optimized as much. It also makes for some
funny looking code to have the built-in dot notation for DOM methods,
mixed in with one or more of the above styles. No perfect solution.
Code gets messy. Life goes on.
Peter
I'd like to be able to share code between my web server (e.g. Apache+Jaxer)
and streaming server environments, for example Red5.
I know that Red5 has some basic JS support but it really is only basic and a
bit of a pain to work with, for example you have to restart the server with
any code changes.
At the moment most of my work is PHP+JS/Flash+AS/Red5, it would be great to
have Jaxer JS/Flash JS/Red5 JS and allow all of them to share a similar code
base and highly streamlined interactions.
For example a page is created with SSJS and served to the client. The user
can click a link using CSJS which tells flash to play a video. The FJS then
makes a request from Red5, which can process stuff pretty much the same as
SSJS (permissions etc.) and stream the video to the client. At this point
SSJS/CSJS/FJS/Red5JS are all able to communicate with each other easily and
they all "know" the same stuff.
Maybe it's just a dream...but then Paul had a dream once :)
Thank you!
If I get a chance, I'll see if I can make some of the other pages look
a bit more like the Modules one does now. Thanks to you and Hannes,
there is now something concrete to talk about.
>
> On Fri, Jan 30, 2009 at 3:34 PM, Peter Michaux
> <peterm...@gmail.com> wrote:
>>
>> On Fri, Jan 30, 2009 at 8:44 AM, Kevin Dangoor <dan...@gmail.com>
>> wrote:
>>
>>> My suggestion is that people who are interested or already have
>>> useful
>>> APIs for this or whatever, create a new page under ServerJS/Modules/
>>> quickly describing the approach (basically a few examples of file
>>> layout and inclusion of modules). If you've already got some docs,
>>> you
>>> can copy and paste that in or something. And then add a link under
>>> "Proposed API" here:
>>>
>>> https://developer.mozilla.org/ServerJS/Modules
Just looked at this page. First:
"Spidermonkey and Rhino offer a load function, but does not have any
specific pattern for namespacing."
At least for Rhino, this is just for the shell. There is no 'load'
function available to JS. (if there is it is new?).
Second, apart from the name 'File' which seems unnecessary limiting in
what it could describe... why would you need this on the server? It
seems to me that all you needs is a shared directory and a runtime
directory.
In the shared directory you dump all your scripts that should live in
a shared/global scope available to all runtime scripts. At startup
they are loaded and cached.
In the runtime directory you 'sort of' mimic your request URIs and
target a single script for the HTTP request. You provide the shared/
global scope to the runtime instance. I say 'sort of' because you may
need to reduce the path by removing request instance specific details
so it can match a generic runtime script. Even further break out the
scripts to target request methods:
a request to /projects has:
- GET.js -- display a list of a user's projects
- PUT.js -- allow authorized users to modify/add a project
- DELETE.js -- allow authorized users to delete a project
(I avoid POST, that and other methods could be MOVE and COPY)
So, on a (servlet container) filesystem it would look like:
- docroot
|- WEB-INF
- scripts
|- shared
|- runtime
|- projects
- GET.js
- PUT.js
- DELETE.js
best,
-Rob
>
>
> On Jan 30, 2009, at 7:48 PM, Kevin Dangoor wrote:
>
>>
>> On Fri, Jan 30, 2009 at 3:34 PM, Peter Michaux
>> <peterm...@gmail.com> wrote:
>>>
>>> On Fri, Jan 30, 2009 at 8:44 AM, Kevin Dangoor <dan...@gmail.com>
>>> wrote:
>>>
>>>> My suggestion is that people who are interested or already have
>>>> useful
>>>> APIs for this or whatever, create a new page under ServerJS/
>>>> Modules/
>>>> quickly describing the approach (basically a few examples of file
>>>> layout and inclusion of modules). If you've already got some docs,
>>>> you
>>>> can copy and paste that in or something. And then add a link under
>>>> "Proposed API" here:
>>>>
>>>> https://developer.mozilla.org/ServerJS/Modules
>
> Just looked at this page. First:
>
> "Spidermonkey and Rhino offer a load function, but does not have any
> specific pattern for namespacing."
>
> At least for Rhino, this is just for the shell. There is no 'load'
> function available to JS. (if there is it is new?).
Yes, the load function is implemented as part of the "shell", but it's
available to any JavaScript that's executed using the shell, including
files you pass in as command line arguments, not just commands you
type into the shell.
That said, it's not particularly very useful, since all paths must be
absolute or relative to the directory you start Rhino from. That is,
they can't be relative to the importing file's path, or in "search
paths" like you have in Ruby, etc.
(I've implemented a really simple "import"/"require" mechanism that
has search paths and relative paths: http://github.com/tlrobinson/jack/blob/54a28398425287bddd9466955d5e8ea616eb8d47/core.js#L10
but the "real" one would also probably have to handle importing
native code extensions, not just simple "eval()"-ing of the file
contents)
This seems like a very application-specific way of doing things. It
would certainly be acceptable as part of a web framework stack, but I
think we should provide general purpose tools for writing any sort of
non-client side JavaScript as well.
>> >https://developer.mozilla.org/ServerJS/Modules
>>
>> Two ideas posted.
>
> I added my proposal, too. I'm calling it 'Pythonic Modules', which is
> catchy and gives a good idea what it is about.
>
> https://developer.mozilla.org/ServerJS/Modules/Pythonic_Modules
I like the Python module loading style you have outlined. It seems
great for a server-only ecosystem of code modules.
My concern is sharing code with the client. If I make a file like the
following for use on the server
// foo.js
var a = function() {};
var b = function() {};
var c = function() {};
then I can use it in another file on the server without polluting the
global namespace.
// bar.js
var foof = require('foo');
foof.a();
If I find that the contents of foo.js are useful in the browser, then
foo.js, as written, will pollute the global namespace in the browser
when loaded.
Another problem is if several files written as foo.js is above are to
be concatenated for use in the browser, how is that to be done in a
straight foward, reliable way?
Peter
I think it could be trimmed down to just the "require" function.
----
Perl allows for the include/export business and although I haven't
written much Perl, it certainly seems better to have the file doing
the including to explicitely specify what is to be included. I have
written the following in Perl
use Mod::Ule ();
to avoid automatically exported symbols.
----
Destructuring assignment for the require-type of script loading was
discussed on the ECMAScript list and seemed quite well liked.
var foo = require('foo');
var a = foo.a;
var b = foo.b;
can be shortened to
var {a: a, b: b} = require('foo');
which can further be shortened to
var {a, b} = require('foo');
which is pretty darn short, very JavaScript-like, and explicitly shows
all variables that appear in a file.
Peter
Destructuring assignment is a JavaScript 1.7 feature. I don't know if
we've determined what version of the language to support, but I would
prefer 1.6 or maybe even 1.5. (SM and Rhino implement at least 1.7,
but JSC and V8 only implement 1.6, I think)
Also, I don't think that last syntax ("var {a, b} = require('foo');")
is valid. The other syntax seems a bit verbose.
Personally, I think the simplest solution is the best: just eval the
code in the global shared scope.
Perhaps wrap the code in a function to give "var" variables "file
scope", while still allowing globals (that's what we do in Objective-J)
Library authors should be responsible and not pollute the global scope
excessively. If they do, users will complain, or someone else will
write a better library.
This has worked pretty well in the browser (at least recently), as
well as in various languages like Ruby.
-Tom
> Also, I don't think that last syntax ("var {a, b} = require('foo');")
> is valid.
Firefox 3
function bar() { return {p:42, q:"hi"} }
var {p, q} = bar()
p // 42
q // "hi"
> Personally, I think the simplest solution is the best: just eval the
> code in the global shared scope.
> Perhaps wrap the code in a function to give "var" variables "file
> scope", while still allowing globals (that's what we do in Objective-J)
If the file is loaded with script tags (which is the way most code
will continue to be loaded) then this wrapping needs to be done when
the file is served or at compile time (which means introducing a
compile time). I'm not in favor of any of these options.
> Library authors should be responsible and not pollute the global scope
> excessively. If they do, users will complain, or someone else will
> write a better library.
>
> This has worked pretty well in the browser (at least recently), as
> well as in various languages like Ruby.
Yes it has.
Peter
> I tend to err towards module should be a language feature,
I agree. On the ES discuss list, some committee members feel that
script loading is up to the host to expose in an appropriate manner
for the containing app. Some members seem to think there should be a
standard loading system. Since script loading involves the containing
app, I side with those leaving up to the app programmer because
otherwise ECMAScript will loose some flexibility as an embedded
language.
> at the very least
> some guidance from Brendan, would be good, as this was an ES4 proposal that was
> killed in the whole ES3.1 debacle.
Packages, namespaces and units seemed like a big, confusing,
overlapping mess in the ES4 proposal. If I remember correctly,
one-by-one each of these was shot down as "inappropriate for the web".
Peter
This is a good point yall...
There is some stuff that we could use, copy or be compatible
with, both in Adobe PDF-side javascript and in ActionScript (which
also has a serverside version). I'll try to add these to the
wiki...
-- MV
> Destructuring assignment is a JavaScript 1.7 feature. I don't know if
> we've determined what version of the language to support, but I would
> prefer 1.6 or maybe even 1.5. (SM and Rhino implement at least 1.7,
> but JSC and V8 only implement 1.6, I think)
>
The latest one, 1.8. Spidermonkey is the reference implementation,
that should be the target.
-- MV
Targeting JS 1.3 or 1.5 is like building a website that
only runs in IE 5.
-- MV
I think the foundational things like module loading and package
management can be done safely with ECMAScript v3 standard (JavaScript
1.5). This has been around for a long time now and is certainly very
common.
Other, non-standard packages could specify newer language versions
with the version number in the package's meta data file. Then it is up
to application authors to decide.
Peter
For the global eval loading system, a file one.js might be written like this
(function() {
global = this;
global.foo = function() {};
global.bar = 33;
})();
Another library file two.js might use the above by evaluating it in
the global scope with "load"
load('one');
var ff = function() {
foo();
};
Wouldn't a file in Helma still be able to reuse the code in the above
files? If Helma overrides "load" with something like the Helma
"include" semantics but where there is no associated export in the
included file I think it would work. That is, Helma would have
something like "include('modulename', '*')" where the * means include
all symbols. I think in Python this would be like "from modulename
import *".
Then if a Helma file has the following it should still work as
expected and not pollute the global namespace.
var two = require('two');
two.ff() // works
two.foo() // error
This would allow Helma to use files intended for the global eval
loading system but not vice versa which actually seems ok.
The only catch is the author of a script intended for the global eval
system would need to explicitly write all load statements even if he
had reason to believe the module is loaded into the global scope in
another file. A library author should have all possible explicit load
statements everywhere anyway, in my opinion.
Peter