throw vs the result

Phil Davis davis.phil at comcast.net
Sun May 1 00:52:51 EDT 2005


J. Landman Gay wrote:
> On 4/30/05 11:27 PM, Phil Davis wrote:
> 
>> Dar Scott wrote:
>>
>>> OK, well, what about a library that exports lots of functions, such 
>>> as a math library?  Functions don't have a separate result for an error.
>>>
>>> Should the error be a special value in the result and propagated 
>>> through?
>>> Or should an error function tell whether there was an error since the 
>>> last call to error function?
>>> Or should an error be thrown?
>>
>>
>>
>> I like the 'special value' idea.
>>
>> What if the last (or first?) param passed to the function by my script 
>> is the value to be returned to my script if an error occurs?
> 
> 
> The HyperCard standard for this was to preceed the value with a special 
> string, commonly "Error:". Then your handler just checks to see if word 
> 1 is that string.
> 
> put myFunction() into tValue
> if word 1 of tValue = "Error:" then
>   -- something went wrong; check the rest of the string
> else
>   -- do your thing
> end if
> 
> Not fancy, but it works.


I like this better than what I proposed. Simple is good.

Phil Davis




More information about the use-livecode mailing list