In the Tutorial Part 2 "Object Variants" section, after the example it says:
As can been seen from the example, an advantage to an object hierarchy is that no conversion between different object types is needed. Yet, access to invalid object fields raises an exception.
However, wasn't the point of this section to show an example of why you don't need an object hierarchy all the time? I feel like this was maybe a typo?
Also: I think this example could use a bit more explaining. This looks like a really cool feature (with the case and all) but I'm not sure I understand it.
Yes, I can indeed remember that that statement was a bit difficult to understand for me...
I would read it as "an advantage IN COMPARISON to an object hierarchy is"
But I am not a native English speaker. Generally it was my impression that tutorial and manual uses really good English. And more explaining can be become boring for the smart people, so maybe you can give examples elsewhere, in your blog/homepage or maybe in a forum thread...
You may read it that way, but in that case you are essentially auto-correcting the error in your head, because that has the exact opposite meaning of what's written.
I just wanted to confirm the intended meaning from the author if possible.
Ah, yes, after you mentioned it's indeed confusing. The example given is object variant but in explanation it's written as object hierarchy.
I think the intended meaning is there's no need to create a whole object isa but instead opting to object variant is clearer. Also it can throw an error if there's no field for a kind of type. cmiiw.
I also just noticed a typo which is that it says "As can been seen" when it should be "As can be seen".
Here's what I'm proposing for those two sentences:
As can be seen from the example, another advantage to this approach is that no conversion between different object types is needed (as would be the case with an object hierarchy), and yet we retain the desired behavior of raising an exception when invalid object fields are accessed.
Or something like that. Not sure if this is overly verbose but I do think it is clearer.
I also noticed that there is an "Object variants" section in the Manual that is longer and better than what's in the tutorial. I wonder if maybe the tutorial should either not have this section at all, or instead have a very short blurb and then just link to the Manual. Seems bad to just duplicate between the two.