Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re^2: More than One Line Comment

by salva (Abbot)
on Nov 17, 2005 at 12:17 UTC ( #509378=note: print w/replies, xml ) Need Help??


in reply to Re: More than One Line Comment
in thread More than One Line Comment

if( 0 and ... ) { ... } ... while( 0 and ... ) { ... }

Replies are listed 'Best First'.
Re^3: More than One Line Comment
by BrowserUk (Pope) on Nov 17, 2005 at 12:54 UTC

    That's pretty good, but has the effect of also disabling any side effects of the conditional. Sometimes that's okay, but mostly you want the rest of the code to run normally and only disable the action within the block.

    It also misses the all the other opportunities where the #{ ... } might work, from bareblocks to inline blocks to subroutine bodies. In fact anywhere where a scoping block can currently exist, if that block is preceded by a #, then the entire block would be made noop.

    It even looks (to the non-expert source diver I am) as if it would be fairly easy to implement. There are some edge cases that would need to be dealt with if it were to be truely universal. For example, to work with the inline blocks of map and grep, it would need to replace the disabled block with a default behaviour. Eg. pass everything through for grep, and the input unchanged for map.

    Dealing with non-core and user-defined map-like subs, (List::Util::reduce/first, etc), would be a problem, but then they need prototypes to function and there are a lot of dark corners surrounding protoyped subs; one more probably wouldn't hurt.

    Any way you cut it, the absence of a proper multi-line comment is a thorn in the side of Perl 5 that I'd love to see corrected in Perl 6. I think the addition of a scoped-comment, one that works with the language structure rather than arbitrary lines, would be a unique and powerful feature of the new language.

    The only good argument against it I've seen is the "not very obvious/visible", which as I outlined it above is very valid. However, I see no reason why the syntax shoudn't be extended to be "an open brace preceded by 1 or more #s with no intervening whitespace or other characters. That would allow for people who favour delimiting their comments in very obvious ways to do something like

    if( ... ) ###################################################################### +######{ ... } ## or while( ... ) ########{ ... ... }

    As programmers, our eyes are already tuned to pairing braces, and with proper indentation, it is fairly intuative to see the extent of the block(-comment).


    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    Lingua non convalesco, consenesco et abolesco. -- Rule 1 has a caveat! -- Who broke the cabal?
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://509378]
help
Chatterbox?
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (6)
As of 2017-10-22 16:28 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My fridge is mostly full of:

















    Results (273 votes). Check out past polls.

    Notices?