<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On 30 March 2014 11:42, Walter Bright <span dir="ltr"><<a href="mailto:newshound2@digitalmars.com" target="_blank">newshound2@digitalmars.com</a>></span> wrote:<br>
</div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="">On 3/29/2014 6:11 PM, deadalnix wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
I'm talking about interface here. The way they are implemented in most new<br>
language is via a struct that contains:<br>
  - pointer to the object<br>
  - pointer to vtable<br>
<br>
That way to don't make object bigger when they implement an interface,<br>
</blockquote>
<br></div>
True, but why is this a problem?</blockquote><div><br></div><div>The most annoying thing about a hidden vtable pointer is it breaks alignment. If there is any SIMD (vector, matrix, etc) or other aligned value in the class, you have to start worrying and compensating for the hidden member.</div>
<div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="">
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
and you don't need cascaded load to call methods.<br>
</blockquote>
<br></div>
True, but on the other hand, it takes up 2 registers rather than one, costing twice as much to copy around, store, pass/return to functions, etc.</blockquote><div><br></div><div>2 registers are used anyway; it will just populate the second register when it fetches the vtable pointer.</div>
<div>There is an additional register used when passing a class pointer to a function, but I'd like to see statistics on function args that include a class pointer. In my experience, functions that receive a class as an argument are the sort of functions that rarely receive many arguments. I notice that classes tend to EITHER receive a class pointer, or receive many arguments to do some work (and not a class pointers). I don't imagine it affecting the arg register availability significantly in practise. Slices certainly have a much greater impact on arg register availability, and they haven't shown to be a problem.</div>
<div><br></div><div><br></div><div>This is an interesting idea. Something I never thought of, and I think I like it!</div></div></div></div>