Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What _did_ the C operators /\ and \/ do?

Anyone can "declare" ones own operators in C.... that is if one is a C compiler guru and has the source code to the C compiler! ;-)

Further questions to puzzle:

  1. How are these operations done in C99? gcc? ...
  2. And why were /\ & \/ dropped?
  3. Which types were the /\ and \/ operators valid for?

Googling for "/\ \/" naturally returns nothing. Wikipedia has a page for neither /\ nor \/. But I have spotted form similar operators are built into the XML character entities!


Source added: I found the offending example in the PDP's cc source file "c00.c":
/*  * Return the next symbol from the input.  * peeksym is a pushed-back symbol, peekc is a pushed-back  * character (after peeksym).  * mosflg means that the next symbol, if an identifier,  * is a member of structure or a structure tag or an enum tag  */ symbol() { ...  case BSLASH:   if (subseq('/', 0, 1))    return(MAX);   goto unkn;   case DIVIDE:   if (subseq('\\', 0, 1))    return(MIN);   if (subseq('*',1,0))    return(DIVIDE); ... } 


Actual Implementations: The /\ and \/ operators date back as far as Sixth Edition Unix 1975 (so far). Examples: Unix V6(1975), Unix V7(1979) and more currently BSD 2.11(1992-2008)
like image 804
NevilleDNZ Avatar asked Oct 08 '09 22:10

NevilleDNZ


People also ask

What does the operator do in c?

C language supports a rich set of built-in operators. An operator is a special symbol that tells the compiler to perform specific mathematical or logical operations.

What is operators and its types in c?

Summary. An operator is a symbol which operates on a variable or value. There are types of operators like arithmetic, logical, conditional, relational, bitwise, assignment operators etc. Some special types of operators are also present in C like sizeof(), Pointer operator, Reference operator etc.

What is &= operator in C means?

The &= operator concatenates the String expression on its right to the String variable or property on its left, and assigns the result to the variable or property on its left.


2 Answers

Neither /\ nor / are defined as operators in the ISO C89 standard, and I don't think they were ever defined in any earlier version. And they are definitely not defined in C99 as far as I know.

Here's a draft of the ANSI C89 standard, for reference: http://flash-gordon.me.uk/ansi.c.txt

(You are likely a victim of some weird arcane preprocessor magic)

like image 140
Tamas Czinege Avatar answered Sep 28 '22 00:09

Tamas Czinege


\/ looks like sup and /\ looks like inf. They could also be ∨ and ∧, respectively.

I don't remember ever seeing these in K&R 2nd edition or any other C book.

like image 21
Sinan Ünür Avatar answered Sep 27 '22 23:09

Sinan Ünür