[Laszlo-dev] how many args is a dependency function supposed to have?
P T Withington
ptw at openlaszlo.org
Wed Apr 2 17:19:41 PDT 2008
[cc-ing laszlo-dev for archiving]
The dependencies method for a method is called will all the arguments
that the method is called with, plus, prepended to those args are the
object the constraint is on (the first argument) and the object the
dependency method is called on. The safest thing for a dependency
method that does not need any of these would just be to say
`(...ignore)`.
I suspect all the dependency methods are wrong because arg count was
never checked in the past.
Don't be fooled, like I always am by the two kinds of dependencies
methods:
1) The ones like your example, which compute the dependencies of a
method that might be used in a constraint
2) The dependency method for a constraint (which takes no arguments),
which is automatically generated by the compiler and which is called
to find the events to register on for updating the constraint.
The class 1 dependency methods are always written by hand, and they
are used to make a method work in a constraint. The compiler only
automatically analyzes the constraint expression. It does not delve
into functions or methods that are called in the constraint
expression, unless they have hand-written dependency methods.
On 2008-04-02, at 18:50 EDT, Henry Minsky wrote:
> I get this error:
>
> [trace] dummy LzBrowser getInitArg declared in core/dummyclasses.js
> [Fault] exception, information=ArgumentError: Error #1063: Argument
> count mismatch on LzView/$lzc$getMouse_dependencies(). Expected 0, got
> 3.
> Fault, <anonymous>() at $lzc$class_dragstate.as:26
> 26 return [this, "drag_axis", this, "__dragstate_xdoffset", this,
> "x"].concat(this["$lzc$__dragstate_getnewpos_dependencies"] ?
> this["$lzc$__dragstate_getnewpos_dependencies"](this, this, "x",
> this.immediateparent.getMouse("x") + this.__dragstate_xdoffset) :
> []).concat(this.immediateparent["$lzc$getMouse_dependencies"] ?
> this.immediateparent["$lzc$getMouse_dependencies"](this,
> this.immediateparent, "x") : [])
> (fdb) q
>
> The LzView method and dependency method are
>
> */
> function getMouse( xory ) {
> if (this.__movecounter != LzGlobalMouse.__movecounter) {
> this.__movecounter = LzGlobalMouse.__movecounter;
> this.__mousecache = this.sprite.getMouse(xory);
> }
> if (xory == null) return this.__mousecache;
> return this.__mousecache[xory];
> }
>
> /** @access private */
> function $lzc$getMouse_dependencies( ) {
> return [ LzIdle, "idle" ];
> }
>
> So what args should a dependency function expect to get called with,
> and are there always the same number?
>
>
> --
> Henry Minsky
> Software Architect
> hminsky at laszlosystems.com
More information about the Laszlo-dev
mailing list