Inline Classes and extends

August Nagro augustnagro at gmail.com
Tue Dec 10 18:31:01 UTC 2019


Ah, I see what you mean!

Appreciate the quick response.

> On Dec 10, 2019, at 12:21 PM, John Rose <john.r.rose at oracle.com> wrote:
> 
> On Dec 10, 2019, at 10:17 AM, August Nagro <augustnagro at gmail.com> wrote:
>> 
>> One question I have is about `extends`. I understand that inline classes cannot extend IdentityClass, but what about other inline classes? I have a lot of classes that would make sense as inline, but are held back by their superclass (which also could be inline).
> 
> One thing you get with the extra indirection of reference objects
> is layout polymorphism, the power to have one type which points
> at two or more distinct layouts.
> 
> If you get rid of the pointer (which is a must for inlines, so they
> can “work like an int”), then you also lose the ability to represent
> layout polymorphism.
> 
> It’s like in C++ when you try to mix inheritance and by-value storage
> of instances:  Stuff goes wrong, awkwardly.
> 
> struct A { int x; }
> struct B : public A { int y; }
> A avar; avar.x = 1;
> B bvar; bvar.x = 2; bvar.y = 3;
> A anotheravar = bvar;  // what happened to the 3??
> 
> — John



More information about the valhalla-dev mailing list