On 4/8/2010 12:27 AM, Max Carlson wrote:
On 4/7/10 1:52 PM, P T Withington wrote:
On 2010-04-07, at 16:23, Max Carlson wrote:

On 4/7/10 12:58 PM, P T Withington wrote:
[...]

Finally, we can't do it only for debug mode unless you want the
situation that started me down this path -- the user who complained
that his app works in debug mode (which catches and neuters all
errors) but fails when he turns off debugging. I think we want to
always catch and ignore these errors (because that is the LZX way,
inherited from swf8). We just need to decide if we _always_ want to
warn about these, or if we want a special 'debug constraints' mode
that turns on these warnings.

Right, got it.

I disagree with Tucker. I think we want to propagate this development style:
First write the application and run it in debug mode, then resolve all errors reported in the debugger and finally test and deploy your application in non-debug mode. Therefore non-debug code should be made as fast as possible, only debug code should catch errors and provide users with appropriate (!) messages to find the errors and give hints how to handle them. For example the following application works perfectly in swf8 (debug and non-debug mode), but it fails for swf9+/dhtml in non-debug mode. So Tucker's statement about "always catch and ignore .. errors" isn't even our current development strategy.

<canvas>
  <script>(new Object).bla();</script>
  <text>This text is only created if the script error is handled</text>
</canvas>


The question is: when you constrain to function that does not have a
dependencies method, should you get a warning (because you might
wonder why your constraint does not update) or should it silently
succeed (because that is what happens in swf8 and DHTML right now)?

It seems like you might want to be able to constraint to arbitrary
functions and have the event system default to lz.Idle.onidle as a
dependency. There should still be a warning in debug mode, so folks
know to update this for efficiency.

I would rather make there be a way for people to write the dependency
method for an arbitrary function.

Sounds fair. I'll file an improvement for this.

1+ for the improvement request.

Concerning Tucker's initial question whether constraints to function without a dependencies method should generate a warning: I've attached a lzx-application which demonstrates the usage of <mediastream> and <videoview>. The application uses a simple class (<ftext>) to show formatted text. In that <ftext> class, a constraint on a "_format()" method is created, "_format()" works as a trampoline for the inherited "formatToString()" method. In this use case I don't want to see any warnings. (And neither a dependency to onidle.) This seems to be the expected behaviour, too. If you search for /\${[^}]*[a-zA-Z]+\([^}]*}/ in the components directory, you'll get over 60 hits. Inspecting these constraints reveals that many of them use functions of the Math object. And the Math object clearly doesn't have any dependencies methods. (If you wonder why I needed to add the "_format()" method, well, guess what happened in swf9+ when I used this constraint "${this.formatToString.apply(...)}" ;-) )


Also, while trying to make the error message that you get more
useful (by telling you which constraint it is that is not getting
its dependencies right), I notice that we get a pile of "failed"
dependencies already, that are just silently ignored. These seem to
come from dependencies that perhaps are evaluated too soon and hence
the context of the event they want to listen to does not yet exist.
It seems we might want to get a warning on those too?

That would be great!

Again, the question is whether we want to do this always, or have a
mode for it.

It sounds like there should be a mode for this to keep from being
flooded by warnings - but that could be added as an improvement later,
perhaps with the special 'debug constraints' mode you mentioned above.

Without further information about the failed constraints, I'd say that any constraint with an invalid reference should be reported as an error to the user. But sometimes sloppy dependencies methods are expected by the users, see LPP-6594...
<canvas>
    <mediastream name="ms" type="http" 
url="http://www.archive.org/download//JudgeMediaTestVideoFile_0/video.flv"/>
    <videoview type="http" width="320" height="240" stream="canvas.ms"/>

    <view x="340" height="90" layout="inset:10; axis:y">
        <ftext fmt="URL: %s" args="${[canvas.ms.url]}"/>
        <ftext fmt="Progress: %5.1f%% loaded" args="${[100 * 
canvas.ms.progress]}"/>
        <ftext fmt="Time: %04.1f of %04.1f seconds" args="${[canvas.ms.time, 
canvas.ms.totaltime]}"/>
        <ftext fmt="[%s] [%s] [%s]" args="${[link('play'), link('pause'), 
link('stop')]}"
                fontstyle="bold" valign="bottom" options="ignorelayout"
                ontextlink="canvas.ms[arguments[0]]()"/>
    </view>

    <class name="ftext" extends="text" text="${_format(this.fmt, this.args)}">
        <attribute name="fmt" value="" type="string"/>
        <attribute name="args" value="[]" type="expression"/>
        <method name="_format" args="f, a">
            return this.formatToString.apply(this, [f].concat(a));
        </method>
        <method name="link" args="text">
            return this.makeTextLink(text, text);
        </method>
    </class>
</canvas>

Reply via email to