On Dec 7, 2007, at 1:51 PM, P T Withington wrote:
On 2007-12-07, at 13:27 EST, Donald Anderson wrote:
On Dec 7, 2007, at 12:36 PM, P T Withington wrote:
Maybe we just need to think a bit more about how we are going to
convert the user application into something compilable.
I guess we decided that the user application needs to be a
class? The question is, whether the globals in the old app
should be instance variables, or, should they be class
variables? If LzTestManager were a class variable, then it would
be 'in scope' without needing `with(this)`.
I just tried
static var LzTestManager
and it is not seen. I need to qualify it ---
DefaultApplication.LzTestManager.failAssertion(errmsg);
That's weird. My reading of AS3 scope rules is that attributes of
the class object are in scope to each other.
But, do we really have to put the user app in a class? The AS3
book seems to imply you can have code in a package that is not in a
class (and that it should behave like our normal expectations for
top-level code, except that it will be in a package.
Ah, actually you can, it's just not terribly convenient.
If you do this:
package foo {
var globalstuff;
var globalstuff2;
class Application {
...
You can an error that 'A file found in a source-path can not have
more than one externally visible definition.'
But you can't declare them private either, using private outside of a
class is not allowed.
You have to have a separate file for each. I'm keeping a list of
these 'script variables' now,
and I have infrastructure to handle this, so it wouldn't be hard to
generate these.
But, I think the real problem here is just that LzTestManager
needs to be class-ified, rather than trying to simulate the old
Object way of doing things. In which case the reference to
LzTestManager would just need to be replaced with `this`, or,
removed altogether if you rely on AS3's implicit with this inside
methods
there is an implicit this inside methods, but this is a closure,
so explicit qualification appears to be needed.
In java for this situation you have access to anything declared
final, but final cannot be used on vars in AS3.
Are you suggesting .lzx code changes?
Yeah. We should consider that option when the code is written in
such an old-fashioned style.
I can go either way - looking at it now, it's very easy to make these
true global variables,
so I'll do that for now just to get to the next error.
- Don
--
Don Anderson
Java/C/C++, Berkeley DB, systems consultant
Voice: 617-547-7881
Email: [EMAIL PROTECTED]
WWW: http://www.ddanderson.com