`Or` and `&` in Ocaml

`Or` and `&` in Ocaml

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

  1. when this started, and
  2. why this is so.

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 ∨.

3

1 Answer

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.

3

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Chloe Bennett
Author

Chloe Bennett

Chloe Bennett explores the intersection of pop culture, streaming entertainment, digital trends, and contemporary lifestyle. Her weekly commentary reaches thousands of culture enthusiasts.