gnash-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Gnash-dev] Static Members


From: Michael Carlson
Subject: [Gnash-dev] Static Members
Date: Sun, 12 Mar 2006 02:50:33 +0800

Hey Everyone,

I'm going through and implementing some of the basic actionscript
classes, and ran into a problem - I don't know how to create static
members with the current code. The first idea to come to my head was
to add static members to the constructor object itself (to cover case
1 below), as well as adding the member to each instance of the class
when created (in the normal non-static way) using the constructor (to
cover case 2 below).

For reference, examples of the two basic cases (that I can think of)
using Date's UTC function (which is static):

case 1) Date.UTC(params);
case 2) var x = new Date(); x.UTC(params);

However, if the static member is a variable which is non-constant
(which fortunately none I've encountered so far are - maybe none are -
but can the user define a variable like this that is?), this would
cause problems as each instance of the class would have its own
separate version of the variable. Furthermore, at the moment the
constructors are all created as an as_value (of type function), which
seems to be unable to have arbitrarily named "members" like objects do
anyways.

Should we add a new as_value type of "constructor", which has the
ability to hold named members like normal objects? Or should we make
the constructor and the uninstantiated object definition separate
entities in code, in which the static variables would exist in the
uninstantiated object definition (this seems to solve all the problems
I thought of, but it might be overkill and overcomplicate the code)?

What is the proper solution here?

- Mike




reply via email to

[Prev in Thread] Current Thread [Next in Thread]