[Docs] Carefully define the terms "object" and "value" #1638
Labels
documentation
Improvements or additions to documentation
mojo
Issues that are related to mojo
mojo-repo
Tag all issues with this label
Where is the problem?
https://docs.modular.com/mojo
What can we do better?
Mojo has a data model that is very different to Python. Accordingly, the meaning of the terms "object" and "value" need to be reconsidered and potentially redefined, such that they make sense in the context of Mojo's data model.
Current usage of these terms
The Python community doesn't use the term "value" consistently. It is typically used to refer to one of the following things:
The Mojo docs mostly adhere to the latter definition of "value", whereas "object" hasn't really been defined. I don't think "object" should be defined as a synonym for "class instance", because Mojo struct instances exhibit object-like behavior such as construction and destruction, polymorphism (via traits), etc.
In C++, the notions of {struct instance, variable, object} are basically synonymous, but the same is not true in Mojo. This is a consequence of the fact that in Mojo, the contents of a variable can be destroyed (
__del__
) and (re)initialized (__init__
/__copyinit__
) multiple times over the variable's lifetime. Thus in Mojo, it seems fair to say that a variable can hold multiple "objects" over its lifetime, similar to how a Python variable can refer to multiple objects over its lifetime.Next steps
Mojo's data model is still being fleshed out, so perhaps it's too early to attempt to define "object" and "value". However, I believe that it is crucial to define these terms in the near future, so that the Mojo community has a precise lexicon that they can use to discuss and teach Mojo.
A precise lexicon is especially important for people new to programming, because terms such as "object" and "value" are entirely foreign to this demographic, and therefore they can't just gloss over the meaning. In my experience as a teacher, vague and inconsistent terminology is especially painful for beginners. (We've all had past experience with bad teachers who don't actually understand the concept that they are attempting to teach their students. Vague and/or inconsistent definitions are a bad teacher's forte. Let's not give these teachers the ammunition they need 😅.)
The text was updated successfully, but these errors were encountered: