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

The comment from SteveB in the linked-to thread was interesting:

   Most editors i have used highlight the next line in green as a comment, 
   however i have come across one that took me over a year to solve, that is 
   remarkably similar.

        //why does this next line not compile??/
        x = 0;

    because the ??/ operator is a trigraph meaning \
    That was never been highlighted correctly any editor I have used.


wait. So it should have been compiling before the comment was added. Why then was the comment added?


To prove a point.


You know how the usual wisdom is that you can never remove anything from a public interface? I think compiler writers should test that by removing trigraphs. Silently at first, to avoid panic, then announce that a mistake has been fixed where some groups of three characters were lexed improperly into a completely unrelated single character. Never mention that the mistake was in the standard.

I seriously doubt anyone would care if you did it that way.

(Modern versions of gcc (4.5.2 at least) ignore trigraphs by default but issue warnings saying they ignored one and giving the command line option to honor them. But gcc has long honored the dumber parts of the standard more in the breach than the observance.)


I've seen C code on EBCDIC machines that uses trigraphs because some code pages lack #, {, }, etc. Someone probably still needs them.


Are EBCDIC machines such a common development platform that trigraphs should be default on instead of default off with the option to enable?

Though I suspect trigraphs being enabled is a very rare source of bugs to begin with, it seems likely that it is still more common than the scenario of active development on platforms that don't support the normal characters (eg the actual development is done on the platform rather than cross-compiled).


GCC has digraphs that are much more readable than ANSI trigraphs.




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

Search: