jfinn at boxoftricks.org
Mon May 6 14:34:23 UTC 2019
This is from the point of a view of a regular programmer - I don’t write VMs or compilers, though I’m somewhat aware of the issues…
The term ‘inline class’ seems to encourage a mental model where fields, arrays, local variables etc. of inline classes ‘contain’ their objects instead of referring/pointing to them. This seems confusing and wrong. Imagine I change class Point to inline class Point: am I meant to think that every other class with a Point field has now changed to ‘contain’ its Point? Likewise every place that stores a Point in a Point array now does some kind of copying instead of storing a reference? Maybe passing a Point to a method now copies it too? This may be true inside the VM, but it's invisible in the language - they still act like normal references (except for ==), which is indeed the the whole aim of this feature. Inline classes just allow the VM to save memory in an unspecified way, in exchange for certain restrictions. Much like an enum class: for its users it’s (almost) just another class, but for its authors there are restrictions (e.g. subclassing).
Despite almost no change in behaviour, the term ‘inline’ (like contained, flattened) kind of suggests I have to mentally reinterpret every use of my class! Instead: since you'd use this feature to save memory/time, how about the term *compact*, or *mini* (which also implies reduced functionality), or possibly *lightweight* (to hint that these are arguably flyweight objects, but that’s another story).
As for the corresponding term identity class: you’d probably decide a class should be non-inline because you want it to be mutable or subclassable. Identity seems to be over-stressed from the point of view of the programmer: it isn’t that obviously connected with subclassing; and it’s very unimportant for immutable classes. Instead: how about a *full* class, meaning full functionality at the cost of full size. Or just a *normal* or *regular* class.
So Object has subclasses CompactObject (or MiniObject) and FullObject (or NormalObject) etc.?
More information about the valhalla-spec-observers