parsing comments in scripts

Alex Tweedly alex at tweedly.net
Sat Dec 11 14:33:47 EST 2004


At 10:18 11/12/2004 -0800, Mark Wieder wrote:
>Saturday, December 11, 2004, 4:38:59 AM, you wrote:
>AT> that says
> >>  Tip:  You can comment out an entire handler by commenting out its first
> >> line.
>
>Yikes! I really hope this isn't supposed to be true. I regularly put
>comments in the first line of my handlers as documentation. I'd hate
>to think that a 'fix' to some future version would break my code. The
>insertion of comments shouldn't have an effect on the execution of
>code.
>
>Comment added to bug #2468.

I'm not sure I see what you're worried about. Having a comment on the first 
line is OK, and will have no effect.

A line like
     on myHandler pText    -- deal with the new text
is not going to be affected by this tip.

But commenting *out* the line will have an effect on the execution of the 
code - just like commenting out any line of code would.

If I take this fragment
   put 1 into a
   put 2 into b
   put 3 into c
and comment out the second line to get
   put 1 into a
   -- put 2 into b
   put 3 into c
then I've certainly affected the execution of that second line.

So I don't see a bug problem with having
-- on myHandler
having some effect.

I just think it should do what it says in the docs - make all the code 
between that line and the
end myHandler be ignored / have no effect, equivalent to "block-commenting" 
the whole handler.

(Currently it allows any local statements within the handler (probably also 
global statements though I haven't tested that) to take effect at the 
scope-level of the whole script. The same code without the handler line 
being commented out would have had those statements in the handler scope - 
so this can cause very nasty side-effects if the same variable names are 
used in other handlers in the same script.
Another good reason to set explicitVariables to true !!)

-- Alex.


More information about the use-livecode mailing list