Person = ref object of RootObj
name*: string # the * means that `name` is accessible from other modules
age: int # no * means that the field is hidden from other modules
Student = ref object of Person # Student inherits from Person
id: int # with an id field
Personally I was never really happy with that "= ref object of" -- it is verbose without much benefit, you have to know what it means, and in the above variant where Person is already a ref, not an object itself, it may even be confusing for beginners.
In Ruby we have something like
class Student < Person id: int
Would it be a silly idea to allow something like "<" for an alias for "= ref object of" in an type section? I guess it may be silly, but it would be nice to know why it is silly.
I am beginner and indeed I had trouble to understand the sense of object keyword, because for me a type always defines objects. Tuples and enums are objects too and could be predefined types like arrays or strings.
If the object keyword was removed and the type keyword, by default, defines an object maybe ref of keywords might be enough to report an inheritance to the compiler, I guess. And it's lighter to read. If people want a tuple or enum their respective keywords could be added after the = as usual.
But it's also possible that I did not understand the real purpose of the object keyword. ;)
object defines something similar to the C struct. ref may or may not be added to any type (not just an object) and denotes a managed pointer (reference) to the data. of is used to denote inheritance.
type does not always define an object, for instance one can do type anyInt = int or int32 or int64.
In short: not everything is an object (so object should not be the default), ref may or may not be desired (often not). So every piece is there for a reason, and adding a shortcut could possibly add confusion.
In any case, one can improve the syntax with a macro