I agree with Henry's sentiment, but for now, defaultattrs is there
just for this purpose, so that is what I would use (for now).
Unless I have been fooled, node.initialize will merge args with
defaultattrs, so that args takes precedence and will then install
each of those attributes, calling the setter to install if there is a
setter.
In the future, we may change how defaultattrs is implemented, but
rather than jump the gun here, I think you should be consistent with
the other classes for now.
On 2007-06-27, at 07:52 EDT, Henry Minsky wrote:
That is a good question.
I would say that we ought to not use defaultattrs , it is
confusing and I
think it is going to go
away at some point when we rewrite node init.
If a setter needs to be called when the node is initialized, we
should call
the
setter manually in the init code.
So your second method is probably the right one for now, until we
straighten
things
out.
On 6/26/07, Benjamin Shine <[EMAIL PROTECTED]> wrote:
Let's say I'm making a virtual attribute on LzText named "thickness".
Where do I specify thickness's default value? I've ran across three
likely places so far:
in lzx.rnc
by setting defaultattrs.thickness = 0; in LzText.lzs
or, in the constructor, with something like
if ('thickness' in args && args.thickness != null) {
this.setThickness(args.thickness);
} else {
this.setThickness(0);
}
Which one of these is the "right" way, or is there another right way?
Benjamin Shine
Software Engineer, Open Laszlo / Laszlo Systems
[EMAIL PROTECTED]
--
Henry Minsky
Software Architect
[EMAIL PROTECTED]