RELEASE LiveCode 6.6 DP1
Richard Gaskin
ambassador at fourthworld.com
Thu Feb 20 10:37:00 EST 2014
Björnke von Gierke wrote:
> On 16.02.2014, at 22:13, Peter Haworth wrote:
>
>> Seems like it's really meant to detect the
>> infamous "this should never happen" situation rather than expected
>> errors.,
>
> Alright, if that is the case, why isn't it done in the engine WITHOUT
> adding another command? why do WE need to add random commands to our
> code? Wouldn't some message or global property that changes the
> behaviour of bug-detection that the engine already has to do anyway
> be better? In fact, it is my impression THAT ALREADY EXISTS!
Before assert was added we had two general ways to check for runtime
errors: "the result" is sometimes used for reporting errors, and the
errorDialog message is sometimes sent for others (though the "sometimes"
aspect makes me uneasy, but that's another topic).
The key point there is that both only catch things the engine considers
errors.
Assert compliments those by providing for things which may be
syntactically correct and completely executable, yet are errors within
the context of the business logic of your app.
That they can also be used for logging execution errors is merely a nice
extra, providing one-stop shopping for all types of logging and
execution monitoring needs.
Sure, we could write our own handler for some of that functionality, but
managing param evaluation would be a bit more finicky and it would have
to parse the executionContexts to provide similar info - having this
built-in is very convenient.
Many languages support assert, so while it may not be absolutely
essential it's a good nice-to-have that raises the level of
professionalism in LC.
If you're happy working without asserts they're easy to avoid by just
never writing them. :) But I suspect that, like nested behaviors which
were questioned here earlier, while the value of the functionality may
not be self-evident at first, further exploration will yield new
scripting habits that make strong use of them.
In fact, my first reaction was pretty much the same as yours, but I know
Mark Waddingham isn't normally one to waste his time on fluff. So I
spent a little time reading up on how asserts are used in other
languages, and that turned me around.
All that said, there appears to be one omission from the current
implementation:
To use assert well we'd want to use it liberally throughout our code,
but of course that means adding additional overhead to execution.
Most languages that support assert also provide a global means of
turning it off. Some C++ compilers won't even compile assert statements
when the flag is off.
For example, you may want asserts to be evaluated during testing, but
not in the final product.
To bring this new feature to completion I just added a request for a
global property to turn it off:
AllowAssert global property
<http://quality.runrev.com/show_bug.cgi?id=11833>
--
Richard Gaskin
Fourth World
LiveCode training and consulting: http://www.fourthworld.com
Webzine for LiveCode developers: http://www.LiveCodeJournal.com
Follow me on Twitter: http://twitter.com/FourthWorldSys
More information about the use-livecode
mailing list