In OCaml, the infix operators or
and &
are defined as synonyms for ||
and &&
, resp. I like the first group of operators because they are a little easier to type, and they make me think I'm learning something different from conventional languages.
Unfortunately, both or
and &
are marked as deprecated in the manual. I'd like to know
If the designers of OCaml have wrote a rationale for this design decision, I'd like to know where it is located. I'd appreciate for your help.
As a side note, here's what I thought:
Argument 1. ||
and &&
are more friendly to former programmers of C and its descendants.
Counter-argument 1. OCaml is in few ways similar to C. It makes little sense to make it look like C in this particular regard only.
Argument 2. It is more desirable to have similar symbols for both conjunction and disjunction.
Counter-argument 2. In natural languages, we only had a special symbol, &, for conjunction and not for disjunction, and we were happy with that for centuries. Besides, some textbooks in logic, including Mathematical Logic by Shoenfield, use entirely different symbols for disjunction and conjunction, viz., & and ∨.
And is used to connect or join two or more phrases, words, sentences , etc. Or is used to connect two or more possibilities, options, or alternatives . Two conjunctions ─ and as well as or ─ are a part of almost every sentence. Can you imagine how vague and ambiguous sentences would be without these conjunctions?
According to the legal commentators, when used together with “and,” the word “or” usually includes “and” and the “and/or” phrase means “either or both of.” Inclusion of the “/” would not have corrected any error, ambiguity or confusion already inherent in the use of the “and” “or” conjunctive-disjunctive.
Definition of and/or —used as a function word to indicate that two words or expressions are to be taken together or individually language comprehension and/or production— David Crystal.
Please do not use "and/or" in either formal or informal writing. In common English, the "or" is a "non-exclusive or" which means "either A or B, or A and B". When I say "I can have a banana OR I can have coffee" then I am also OK with having both.
It was marked as deprecated in 2001.
I am not aware of any design rationale for this, probably C similarity was the main driving point. Also, or
and &
are keywords in jocaml - that might have been one of the reasons to discourage their use in regular OCaml.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With