views:

1317

answers:

9
+17  A: 

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)

DrJokepu
+1 for weird arcane preprocessor magic. This looks like the kind of thing you might see in an IOCCC entry.
Chris Lutz
+7  A: 

I don't believe I've ever seen those operators anywhere. Ever.

Nick Bedford
Yeah, same here.
GreenRails
Wouldn't mind an operator like this though: `my_bank $ 10000;`
Nick Bedford
+4  A: 

C has never had those operators.

Typically \/ would be an escape code in some string systems, not sure that /\ has ever had any meaning.

Cade Roux
+2  A: 

The Caret (^) performs a bitwise exclusive or.

I don't believe there is a "V" operator. That's the letter 'V' (or something that looks a whole heck of a lot like it). Somebody might want to name a variable that.

T.E.D.
I think the OP means the two-character combinations `/\` and `\/` which are even more meaningless.
Chris Lutz
+10  A: 

Speculation!

If you have spaces around them, then:

a /\ b   ===>   a / b

a \/ b   ===>   a / b

Logic: the preprocessing phase has to deal with backslash and a character after, and is quite likely to treat backslash-space as space, and backslash-slash as slash.

That said, both the SUN C compiler (version 12) and GNU C compiler (version 4.4) reject code containing the backslash. But I could easily believe that old, pre-standard C preprocessors were less careful about it.

Standards compliance

The operators have never been part of an official version of C.

Also, the standard would not allow the interpretation I gave (section 5.1.1.2 Translation phases, in both C89 and C99) - but non-standard compilers are not constrained by the standard, of course.


Added after the source was posted:

Interesting! So it looks plausible for 'a = b /\ c;' to assign the maxiumum of b and c to a, and 'a = b \/ c;' to do the minimum (or, as Greg Hewgill pointed out, more likely vice versa). And, in those days, it was probable that the modern '+=' operators were still written as '=+' and were in fact two tokens (no supporting evidence for this assertion; failing memory again), so the hypothetical 'a =/\ b;' (or, in modern notation, 'a /\= b;') would have been the max-assignment operator, etc.

It also occurs to me that Thompson's ACM Turing Award speech 'Reflections On Trusting Trust' is somehow relevant.

Jonathan Leffler
If someone does this in code I have to maintain, they'd damn well have better left the state...
T.E.D.
@T.E.D. - what about splitting the / and the * of a comment over multiple lines by using backslash-newline?
Jonathan Leffler
`\/` for `sup` and `/\\` for `inf` are established mathematical notation. See also http://en.wikipedia.org/wiki/Lattice_%28order%29
Sinan Ünür
+3  A: 

I doubt they ever meant anything. If they ever did, it was a long time ago. The only major operators I know of that have been removed from C were =+ and =-, which were early synonyms for += and -=. You might want to look at DMR's Primeval C Page for evidence.

Jerry Coffin
+10  A: 
Sinan Ünür
This reminds me of the deprecated <? and >? (min and max) operators and their assignment variants <?= and >?= that G++ used to allow and that I've had the misfortune of encountering.
Joey Adams
You probably guess right: I found implementations of the /\ and \/ operators in both Unix V6 -)
NevilleDNZ
Sinan Ünür
"The internet" says the \ character was added to ASCII by 'Bob Bemer' specifically to allow the /\ and \/ operators. c.f. http://home.ccil.org/~remlaps/www.bobbemer.com/BRACES.HTM - Maybe sometimes - even to this day - MIN and MAX are implemented in C with precarious side effects: eg #define MIN(a,b) ((a<b)?(a):(b))
NevilleDNZ
Just curious -why were the terms 'sup' and 'inf' used instead of what I'd think were the more immediately understandable 'max' and 'min'? The linked pages describing 'Supremum' and 'Infimum' make my head hurt.
Michael Burr
Because, in general, a maximum and a minimum of a set don't need to exists. For example, `[0,1)` has not maximum but its supremum is well defined. See also http://en.wikipedia.org/wiki/Lattice_%28order%29 and associated references.
Sinan Ünür
+7  A: 

I'm not sure about \/, but /\ is a valid construct. It is used to place the two slashes of a single line comment on separate lines. For example:

/\
/ Comment content

This works because the backslash character escapes the newline and the parser continues as if it wasn't there. This will not work if there is a space after the backslash or if the second forward slash is indented. Because of this, it is possible to escape as many newlines as you like, as in

/\
\
\
\
\
/ Still a legal comment.

Backslashes can also be used at the end of regular single line comments to make them continue to the next line, as in

// Yet another comment \
This line is in the comment \\
And so is this one!
Cristián Romo
The language surprises me once again.
GMan
I saw this when I was browsing through the C99 standard and thought, "Hey that's cool! ... and mostly useless."
Cristián Romo
How many comment matching regular expressions handle this correctly? And does it actually matter, except to compiler writers who have to worry about such details? (Answers: very few, and not really.)
Jonathan Leffler
+3  A: 

I'm going to guess that these are a reference to formal symbolic logic:

http://en.wikipedia.org/wiki/Table%5Fof%5Flogic%5Fsymbols

\/ is used to denote disjunction (OR) /\ is used (less frequently) to denote conjunction (AND)

Quintus