is within - a syntax bug?
Frank Leahy
frank at backtalk.com
Tue Mar 23 03:54:03 EST 2004
On Tuesday, March 23, 2004, at 06:10 AM,
use-revolution-request at lists.runrev.com wrote:
> From: Doug Lerner <doug at webcrossing.com>
> Subject: is within - a syntax bug?
> To: How to use Revolution <use-revolution at lists.runrev.com>
> Message-ID: <BC85FA14.2D6DC%doug at webcrossing.com>
> Content-Type: text/plain; charset="US-ASCII"
>
> This results in a syntax error that "what is to the left of within" is
> not a
> point:
>
> addToStatus "within: " & the mouseLoc is within the rect of the
> target
> into withinCheck
>
>
> But rewriting it this way works:
>
> put the mouseLoc is within the rect of the target into withinCheck
> addToStatus "within: " & withinCheck
>
> A compiler bug?
>
> doug
>
No, it's not a compiler bug.
Parsing happens left to right, so in your first statement the compiler
first evaluated
addStatus "within:" &
and decided there was more to evaluate before it could call addStatus.
Then it evaluated
the mouseLoc is within the rect of the target
For explanatory purposes, let's assume the intermediate result of this
statement is "true".
then it tried to parse
addStatus "within:true"
and so it called addStatus with "within:true".
And finally it tried to put the result of the addStatus call into the
variable withinCheck. But, as addStatus isn't a function the whole
thing failed because addStatus didn't return anything.
Anytime you have a complicated expression it's better to use multiple
statements (as you saw), or use parentheses to make sure the compiler
does things in the order you intend.
Best,
-- Frank
More information about the use-livecode
mailing list