Hi Andreas,

Andreas Ecker <[EMAIL PROTECTED]> writes:

> Unfortunately, I doubt there is a single optimal solution to this
> behaviour. It is so fundamental to the JavaScript language itself...
> 
> Data types that are non-problematic as init values of properties are the
> primitive types (Boolean, Number, String). Fortunately, this should be
> true for most of qooxdoo's framework and application code. On the other
> hand reference types work, as their name suggests, only as references to
> complex JavaScript objects (Array, Object, etc.).
>
> This language concept, and its potential problems, needs to be
> understood by every qooxdoo user. 

Of course. :-) I am well aware of what reference types are, and what they do /
how they work.  That's why I said it would be difficult to change the legacy
property system to do anything different.  I can, however, think of a few ways
to defer the setting of default values of properties in a new property
system.  There are a couple of options:

Option 1

    properties :
    {
      initDeferred : "[23, 42]"
    }

Option 2
    properties :
    {
      initDeferred : function() { return new Array(23, 42); }
    }

Instantiation of the object would then automatically do something like:

  prop.value = eval(config.initDeferred);

or

  prop.value = config.initDeferred();

With that in hand ...

> Well, some good news: in our discussion of the new property
> implementation we came up with a practical solution to avoid potentially
> hazardous coding during development: there could be an additional key in
> the property declaration map that indicates that the developer
> explicitly is aware of and wants to have a complex (i.e. reference type)
> init value (as said, something that should not be very common).
>
> Your example code may read:
> properties : {
>   uniqueValue : { init: [23, 42], shared: true }
> }

... this would work wonderfully.  You'd get an error if you tried to use a
reference for the init: value unless you specified that you wanted it to be
shared, and you'd still have the ability to have unique values (even if they
are arrays, javascript objects, etc.) on per-object properties.

Thanks for the response and your consideration of possibilities!

Cheers,

Derrell

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
qooxdoo-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel

Reply via email to