Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Option (3): require both braces and indentation, with a syntax error when they don't match.


I don't see this as different from option 2. Failures will just happen at compilation-time rather than run-time. This has the slight advantage of making those errors easier to track down, but still violates DRY.


Is DRY as important in syntax? I thought the main point of DRY is to avoid writing the same code over and over (code duplication is bug duplication, etc). Are you sure those reasons still apply here, or are we being overly dogmatic in our application of this principle?

(though obviously no one likes pointless repetition or obnoxious syntax.)


Yes, it is important in syntax. You're still entering the same information twice (this time in two different ways, rather than two different places), which allows the possibility that the two conflict (the main problem that DRY prevents), resulting in something bad.


Some people would say that when a compiler blows up telling you "ur doin it rong", that's a good thing.

This is surely why there's so much type information floating around a programming language like Java. (Of course, Java is a little extreme. It's obnoxious to be forced to catch/declare-that-I-throw 50 different exceptions when I do any file I/O, and doesn't bring much to my typical use case. I don't use Java much. :)


These should all be compiler errors because the indentation and the delimiters don't match.

    if (expression)
        statement;
        statement;
    statement;
or:

    if (expression)
        statement;
        if (expression)
            statement;
    else
        statement;
or

    if (expression); {
        statement;
        statement;
    }
So curly brace languages should have a defined formatting standard and anything else should be a syntax error.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: