• archie flockhart (2/12/2009)


    Here's an interesting combination:

    This code works perfectly OK ( the unmatched block comment marker causes no problems because it is part of an inline comment):

    print '1'

    --/*note unmatched block comment marker on this line, following an inline comment marker

    print '2'

    print '3'

    result: 1 2 3

    Now, suppose we are asked to disable the part of the code that prints 1 and 2 ... easy, we say 🙂 ... just put block comment markers around it ...

    /*

    print '1'

    --/*note unmatched block comment marker on this line, following an inline comment marker

    print '2'

    */

    print '3'

    result : Server: Msg 113, Level 15, State 1, Line 1

    Missing end comment mark '*/'.

    oops !

    My attempt to explain the behaviour is: as soon as you are withiin a BLOCK COMMENT, the system ignores all INLINE COMMENT markers. For most statements, this doesn't matter, because the statement will not be executed anyway since it is part of the BLOCK COMMENT.

    But START BLOCK COMMENT /* or END BLOCK COMMENT */ instructions which look as though they should be ignored because they follow a "--" , are actually processed, and may open a nested comment block or close the existing block or cause a syntax error.

    Does that sound about right ?

    Yeah. But you gotta try this. You'll love it!

    /*

    print '1'

    --/**/note unmatched block comment marker on this line, following an inline comment marker

    print '2'

    */

    print '3'

    Tom Garth
    Vertical Solutions[/url]

    "There are three kinds of men. The one that learns by reading. The few who learn by observation. The rest of them have to pee on the electric fence for themselves." -- Will Rogers