Error description: Function: missing '('
Arthur Evans Jr
evans at evans.pgh.pa.us
Thu Jan 3 09:08:01 EST 2002
Brad Allen wrote:
> This function worked in a HyperCard stack,
[SNIP]
> function mindLink distance,time
> return (2 * log (distance)) + (time * log (distance) / 5)
> end mindLink
>
> -=-=-=-=-=-=-=-=-=-=-=- Error List =-=-=-=-=-=-=-=-=-=-=-=-=-=-
>
> Error description: Function: missing '('
> return (2 * log (distance)) + (time * log (distance) / 5)
> Line: 22 Character: 32
> Value:
[SNIP, followed by lots more error messages]
At 21:40 -0800 2002.01.02, Bob Rasmussen wrote:
> "time" is a reserved word in Transcript, which thinks it's the
> built-in function "time()", but with a missing set of parentheses.
This dialog led me to compose a diatribe comlaining about the poor
quality of Rev's error messages. However, in doing so I came to
realize that the situation isn't quite so bad as I had come to
believe. I here post my analysis. It helped me; maybe it will
help others.
First, though, there really are some Rev problems that deserve
attention:
1 If there's a list of Transcript reserved words, I've never found
it. Such a list is badly needed.
2 The error messages reported from accidental misuse of a reserved
word are immensely obscure. For example, in the example above,
since 'time' is a reserved word, the error should have been
reported first on the 'function' line rather than on the 'return'
line. It should not be hard to report
use of a reserved word as a formal parameter
on that line.
Now, let's look at what was reported.
For the first time just now, I noticed that the error report
included the character position where the error was detected.
Here's the report again:
Error description: Function: missing '('
return (2 * log (distance)) + (time * log (distance) / 5)
123456789012345678901234567890123456789012345678901234567890
Line: 22 Character: 32
Value:
I've added a character count line. The error was detected in
character position 32, which is where 'time' starts. That's
immensely helpful in that it suggests that 'time' is the problem.
If you look up 'time' in the Transcript dictionary, you learn that
'time' is a function, and therefore a reserved word. Aha! I wish
I had made this observation long ago.
HINT TO THOSE WRITING DOCUMENTATION FOR THOSE COMING FROM
HYPERCARD: Include an analysis of error messages like what I've
just written. None of the Tutorials I read say anything about
error messages.
Finally, there's a better way to report where the error is detected:
Error description: Function: missing '('
return (2 * log (distance)) + (time * log (distance) / 5)
-------------------------------^
The caret under the error is easier to deal with than counting
characters. (I think it's safe to assume a fixed width font.)
One more hint to those trying to deal with a long list of error
messages from a single line: Look only at the first message, and
ignore all the others. If you can fix the problem reported in the
first message and recompile, the other problems will likely
disappear.
Art Evans
More information about the use-livecode
mailing list