Good morning,

I just followed your advice and simplified defineClass.js a bit (pushed to
GitHub repo and GitHub pages, so you should see the update, maybe after
cleaning your browser cache).

Another thing:
Because defineInterface.js is really so small I thought about uniting both
define*.js into one file / AMD module.
Would look like this:
define(["runtime/runtime.js"], function(AS3) {
  function A() {
    ...
  }
  // either...
  AS3.class_(A, ...);
  // ...or
  AS3.interface_("com.acme.I", []);
});

Of course, AS3 could be dynamically renamed by the compiler to any free
variable name.

We could also move all the AS3 helper functions (as, is, bind, cast, etc.)
into one module (maybe even the same module), but that would actually
introduce one more property dereferencing when using these functions at
application run time (in contrast to start-up time, at which classes and
interfaces are defined, where ultimate performance is not so much of an
issue).

What do you think?

-Frank-

On Fri, Dec 21, 2012 at 12:53 AM, Kevin Newman <capta...@unfocus.com> wrote:

> I wonder if you could use the second argument of Object.create to reduce
> the number of times Object.defineProperties appears in the source (and if
> it would matter at all).
>
> // Example where we create an object with a couple of sample properties.
> // (Note that the second parameter maps keys to *property descriptors*.)
> o = Object.create(Object.**prototype, {
>   // foo is a regular "value property"
>   foo: { writable:true, configurable:true, value: "hello" },
>   // bar is a getter-and-setter (accessor) property
>   bar: {
>     configurable: false,
>     get: function() { return 10 },
>     set: function(value) { console.log("Setting `o.bar` to", value) }
> }})
>
>
> Kevin N.
>
>

Reply via email to