简体   繁体   中英

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

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM