What is a Unit?
Is this another attempt at creating a class system?
Here we are putting the emphasis on the aspect of "classes" as things we can create multiple, similar instances of, rather than the other aspects relating to being able to categorise these units as we find them in the wild. In a dynamic language, categorisation should be done using duck typing instead of type checking.
new keyword can be confusing and error-prone. For example, if you forget to invoke a constructor function using the
new keyword, the result is a silent failure. No error, and nothing works. Just confusion. Worse yet, using
new keyword. Once you get used to the syntax, the result is a simple and straightforward way to define new sorts of objects.
How do I define a Unit in code?
Here's a simple template you can use when defining your own units: