If an OCaml package is a set of OCaml modules, what do you call a set/group/collection of OCaml classes?
In Java, a package is a set of Java classes. Reference: Java Packages
If an OCaml package is a set of OCaml modules, what do you call a set/group/collection of OCaml classes?
In Java, a package is a set of Java classes. Reference: Java Packages
There is no name for a collection of classes in OCaml.
However, in many languages there is a name for a collection of compilation units, which happen to be classes in Java. (disclaimer: I never used java). In OCaml, compilation units are modules which can be bundled into a library.
Language | Compilation unit | Bundle of compilation units |
---|---|---|
C (unix) | source file .c compiled into object file .o | archive library .a, dynamic libraries .so |
Java | source file .java compiled into a .class | package |
OCaml (native) | source file .ml compiled into .o, .cmx | library .a, .cmxa |
Ocaml (bytecode) | source file .ml compiled into .cmo | library .cma |
How about âSchoolâ - seems appropriate
To add on to monoidoidâs answer, purely in terms of organizational hierarchy, in the OCaml ecosystem,
module item < module < library < package
Packages are what can be installed using opam.
And a class is considered a âmodule itemâ. (So is a module, of course.)
I am not happy with the paralelism between Java packages and archives (.a, .cms, .cmxa).
In Java, a package is a hierarchical way to name classes and avoid conflicts. The usual convention is to use your reversed domain (com.ibm.my_research_unit.my_class is unlikely to match your java class name !). There are some added semantics with protected
which opens the access from the same package, but not from outside.
And Classes (whatever the packages) are typically bundled in .jar
files which are the homologous of .a
, .cma
, cmxa
.
The model has been evolved in Java 9 with modules. Modules are better encapsulated since only âexportedâ classes are visible from other modules.
If possible, can someone please kindly let me know how can we recommend Mr. Betteridgeâs/njbâs suggestion to be formally included in the OCaml language specification?
This is because people who want to use object-oriented programming, or object-functional programming, with OCaml, can use this concept to model a school of classes in UML diagrams.