----- Original Message -----
From: "Ben St Johnston" <ben@...>
>
> That might not always work. If you are providing a library of "classes"
> which people can extend,
But that's not what we are doing. We are providing an object-oriented
toolset, which people can incorporate into higher-level scripts. There will
be a collection of high-level scripts and behaviours that use the main
library as well, so perhaps such classes would fall into that category, but
that is not part of the main project.
> It is also the case that lingo cannot contruct javascript objects and vice
> versa, although given a reference either language can use objects written
> in the other language. Therefore, you should provide factory methods (e.g.
> createMyObject()) rather than expecting people to call new MyObject or
> script("MyObject").new().
This is true, at some point we need to have a generic factory object as part
of the library anyway, in fact it's one of the things we should have already
addressed.
If you want to instantiate ECMAScript objects in Lingo then you can simply
write your scripts slightly differently - in fact, this method is
preferrable in ECMAScript because of the way inheritance works (I won't get
too into that just now). What you do is this:
function someobject_memberFunction()
{
return this.someProperty;
}
function someobject()
{
var temp = new Object();
temp.someProperty = "a property";
temp.memberFunction = someobject_memberFunction;
return temp;
}
As opposed to:
function someobject()
{
this.someProperty = "a property";
this.memberFunction = someobject_memberFunction;
}
(the latter requires the new operator, whereas the former is simply a
self-contained factory for the object)
BTW, I always declare member functions outside of the class definition and
use that convention, i.e.: classname_functionname. I haven't been doing much
JavaScript programming lately, but if I were, I would start using this
instantiation method more because JavaScript does not have any inheritance
in the C++ sense, but by using these self-contained factory functions
instead of a class function, you can create descendants in the same way as
any other type of object so the whole thing becomes a lot more transparent.
Unfortunately there is no reverse equivalent for creating Lingo objects in
JavaScript (that I know of) but a generic factory class within the openLingo
framework would solve the problem.
- Robert