parsing comments in scripts
Alex Tweedly
alex at tweedly.net
Sun Dec 12 07:19:27 EST 2004
At 23:32 11/12/2004 -0700, Dar Scott wrote:
>On Dec 11, 2004, at 12:33 PM, Alex Tweedly wrote:
>
>>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.
>
>I'm not comfortable with this.
>
>To do this, it would have to ignore everything from the commented out 'on'
>or 'function' line down to the 'end', including 'local', 'global' and
>'constant' lines. To do this, it would have to know the line is a
>commented out 'on' or 'function'. To do this, it would have to look
>inside and parse the contents of comments. This violates the trust
>between the compiler and me. That which is in a comment belongs to
>me. And besides, what if I have a temporary first line commented out, or
>for some reason include "on Christmas morning" in some line of a comment.
Yeah - it certainly has some difficulties. In some ways I don't care
whether they change the docs or the app - I just don't like them disagreeing.
>It is straightforward to select the entire handler and select "Comment"
>from the script menu. An alternative might be to temporarily change the
>spelling of the name.
That's what I've always done (since I didn't know about this "feature"),
and what I intend to keep on doing - so I'll never (deliberately) use this
feature, and hopefully I will never be affected by it.
In this case, I don't think it's good enough to change the docs to reflect
what the code does - because the current behaviour is a trap for the
unwary. Often, I'll use the same (local) variable names within multiple
handlers (e.g. tLine is a favourite of mine :-) If I were to use this
feature, it would then change all those occurrences of tLine from
handler-local to script-local - i.e. they are all the same variable - so
hard-to-find bugs are all too possible.
I'd prefer if they removed the feature entirely, or as you suggested used
"disabled" or some such keyword rather than a comment, preceding the first
line of the handler.
-- Alex.
More information about the use-livecode
mailing list