Re: New switch/case idea

new topic     » goto parent     » topic index » view thread      » older message » newer message
jeremy said...
Mike777 said...
said...

At the moment we have the same situation with the return keyword. I used to just stick a return in a function to have it ignore the code below, though that would generate a warning.

With multiline coments though, do we really still need this?

Absolutely. If I'm testing something and want to quickly disable 7 blocks of code, I need the break and to force me to block comment would be a huge drain.

I disagree totally here. break can introduce bugs as it changes the logical flow of your code. You may be breaking to a place you didn't count on. When you comment the code out, you comment it out and it's gone. You know what I mean by block/multi-line comments, right?

This is now valid in Euphoria:

if TRUE then 
    a = 10 
    b = 20 
 
    -- there is some bug here, let's get rid of this code 
    /* 

    a = b * 20 
    b = c * 90 
    d = a + b / 39 
    */ 
end if 

That whole block of code is now gone from IL. It's all a comment. There is no reason to:

if TRUE then 
    a = 10 
    b = 20 
 
    -- there is some bug here, let's get rid of this code 
    --a = b * 20 
    --b = c * 90 
    --d = a + b / 39 
end if 

anymore since we have multi-line comments. A multi-line comment is much more clear, robust and much less error prone then trying to use break or goto to skip a section of code that you are testing/not testing.

Jeremy

Well, I can't argue with the fact that a break can potentially change the logic flow. If that is the only criteria for disallowing it in this circumstance, I feel the argument is fairly weak. If there is one area where Euphoria does not shine it is in the area of debugging, so I would err on the side of aiding that effort, even if it allowed me some rope that I *might* end up hanging myself with.

Encasing a short bit of code in a block comment is not a problem.

But just like the comment I made a few posts ago, don't confuse these short examples for real-world programs. I might have a SWITCH (or any other logic selection statement) associated with blocks of code that are multiple-screens long. And I might have 30 of them, rather than just one or two. And if you force me to find both the top and the bottom of each section, to insert the block comment indicators (or remove them), I promise you I will instead use the GOTO construct.

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu