Understanding concepts and entities
Concepts and entities are part of the nominal system of types that Bosque offers. They help us to transfer our experience in object-oriented programming to our Bosque programs. Both of these constructs have been already mentioned in Chapter 5, Types and Operators. Let’s quickly recall what they are before we jump into more detail.
Concepts
Concepts are entirely abstract types that we will use to model some generic and non-instantiable objects, reminding us of the abstract classes that we will find in other languages.
To declare a concept, we will use the concept
statement followed by an identifier as follows:
concept Animal { }
Within the block enclosed by the braces, we can define some functions that could be overwritten later and some properties that will be inherited by the entities that will implement this concept.
Let’s see what a concept
statement would look like with field
and method
:
concept Animal { ...