Hacker News new | past | comments | ask | show | jobs | submit login

In addition to trigraphs, there are apparently a set of C alternative tokens defined as follows:

  #define and &&
  #define and_eq &=
  #define bitand &
  #define bitor |
  #define compl ~
  #define not !
  #define not_eq !=
  #define or ||
  #define or_eq |=
  #define xor ^
  #define xor_eq ^=
I suppose that allows for code like this:

  if (x or not y or not z) {
      return 1;
  }
https://en.wikipedia.org/wiki/C_alternative_tokens



Makes for great obfuscated C++.

    template <typename T>
    void print(T const bitand foo) {
        std::cout << foo << std::endl;
    }


    void print(auto const bitand foo) {
        std::cout << foo << std::endl;
    }
Since C++20.


The instructor at the branch college where I learned C++ in the late 90's taught us that those were the preferred operators and that the old operators belonged in the wastebasket of history along with printf and str* functions.

It made for some amusing group projects when I got to university, when classmates had never seen those operators and were trying to figure out where they were coming from and why I would write such silly things. I trolled them by replacing all my brackets with `begin` and `end` in the next assignment before moving to the standard use of C operators for the rest of the class.




Consider applying for YC's Spring batch! Applications are open till Feb 11.

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

Search: