Re: Error handling (was Re: "nan" v. try-catch for arithmetic)

2014-06-26 Thread Paul Dupuis
On 6/26/2014 12:23 PM, Peter Haworth wrote: > On Thu, Jun 26, 2014 at 8:22 AM, Richard Gaskin > wrote: > >> Is there a simple rule that would allow scripters to understand when >> try-catch is necessary and when the result should be checked instead? >> >> If not, should there be? >> >> Or perhaps

Re: Error handling (was Re: "nan" v. try-catch for arithmetic)

2014-06-26 Thread Peter Haworth
On Thu, Jun 26, 2014 at 8:22 AM, Richard Gaskin wrote: > Is there a simple rule that would allow scripters to understand when > try-catch is necessary and when the result should be checked instead? > > If not, should there be? > > Or perhaps better yet, could error handling be made uniform, maybe

Error handling (was Re: "nan" v. try-catch for arithmetic)

2014-06-26 Thread Richard Gaskin
J. Landman Gay wrote: > On 6/24/2014, 1:02 PM, Graham Samuel wrote: >> I get a result, "nan", and the catch doesn't fire. Why not? Maybe >> someone can explain what the engine is doing here - or is it just an >> obscure bug? > > A "catch" only triggers when there is a script error. In this case >

Re: "nan" v. try-catch for arithmetic

2014-06-24 Thread Mark Wieder
Graham- Tuesday, June 24, 2014, 11:02:56 AM, you wrote: > I get a result, "nan", and the catch doesn't fire. Why not? Maybe > someone can explain what the engine is doing here - or is it just an > obscure bug? It fires for me in either case. To get the actual error code, change the code to try

Re: "nan" v. try-catch for arithmetic

2014-06-24 Thread Jerry Jensen
On Jun 24, 2014, at 11:02 AM, Graham Samuel wrote: > If I put > > sqrt(-1) > > that fires too. But if I put > > (-8)^(2/3) > > I get a result, "nan", and the catch doesn't fire. Why not? Gee, you'd expect sqrt(-1) and (-1)^(1/2) to evaluate the same. Apparently, the sqrt function checks th

Re: "nan" v. try-catch for arithmetic

2014-06-24 Thread Mark Schonewille
Hi Graham, If I execute (-8)^(2/3) in LiveCode 6.6.1, I get "execution error at line 7 (pow: range error (overflow)), char 17", i.e. an execution error instead of NaN. -- Best regards, Mark Schonewille Economy-x-Talk Consulting and Software Engineering Homepage: http://economy-x-talk.com Tw

Re: "nan" v. try-catch for arithmetic

2014-06-24 Thread J. Landman Gay
On 6/24/2014, 1:02 PM, Graham Samuel wrote: I get a result, "nan", and the catch doesn't fire. Why not? Maybe someone can explain what the engine is doing here - or is it just an obscure bug? A "catch" only triggers when there is a script error. In this case there is no error, "nan" is a legit

"nan" v. try-catch for arithmetic

2014-06-24 Thread Graham Samuel
Hi I have a bit of code that looks for input errors where the user is supposed to write an arithmetic expression into a field. The relevant fragment looks like this try put value(fld "myField") into testResult catch answer "oops, that's not a valid real number. Try again" exit mouseUp