`or` and` & `in OCaml

In OCaml, the infix or and & operators are defined as synonyms for || and && , respectively. I like the first group of operators because they are a little easier to type, and they make me think that I am learning something different from ordinary languages.

Unfortunately, both or and & are marked as deprecated in the manual. I'd like to know

  • when did it start and
  • why is this so.

If OCaml designers wrote the rationale for this design decision, I would like to know where it is. I would be grateful for your help.

As a side note, here's what I thought:

Argument 1. || and && are friendlier to former C programmers and his descendants.

Counter-argument 1. OCaml is a bit like C. It makes no sense to make it look like C only in this particular respect.

Argument 2. It is desirable to have the same characters for both conjunction and disjunction.

Counter-argument 2. In natural languages, we had only the special character &, for conjunction, not for disjunction, and we have been pleased with this for centuries. In addition, some logic textbooks, including the mathematical logic of Shoenfield, use completely different characters to disjunction and connect, namely, ∨.

+7
ocaml
source share
1 answer

It was marked obsolete in 2001 .

I do not know any justification for the design for this, probably the C-affinity was the main driving force. In addition, or and & are keywords in jocaml - this may be one of the reasons that prevent their use in regular OCaml.

+5
source share

All Articles