Domanda

I have seen so far:

  1. first-class function
  2. first-class fields
  3. first-class module

I can understand first-class function and it means functions can be used as arguments, as well as values,etc.

But what's the meaning of the other two first-class?

What is the general meaning of first-class in OCaml's context?

È stato utile?

Soluzione

I've never encountered a special meaning of "first class" in the context of OCaml. It's being used in its usual sense in all the places you give. I.e., a first-class value is one that can be passed to and returned from functions.

The idea of first-class record fields seems to be that you could write a function that works for many different fields (when represented as Field.t). In other words, you can pass individual record fields around as independent Field.t values.

First-class modules are also called that because you can pass them around as independent values.

Generally, terms of art like first-class don't have an "exact" meaning. In fact I would claim that's often why they're so useful.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top