-
Notifications
You must be signed in to change notification settings - Fork 13.3k
reference: vtable entries are resolved at runtime #31677
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
I think the reference was right, but perhaps a bit unclear: The vtable itself is built at compile time, so the vtable entry for all methods is known at compile time, but it's not known which method the entry actually points to. |
/cc @nikomatsakis @aturon what is the best wording here? |
I agree with @jonas-schievink. It'd be mildly more clear as
instead of:
but, honestly, the whole paragraph could probably use a rewrite for clarity. |
@@ -3565,7 +3565,7 @@ Each instance of a trait object includes: | |||
implementation (i.e. a function pointer). | |||
|
|||
The purpose of trait objects is to permit "late binding" of methods. A call to | |||
a method on a trait object is only resolved to a vtable entry at compile time. | |||
a method on a trait object is only resolved to a vtable entry at runtime. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I would probably say something like "Calling a method on a trait object results in virtual dispatch at runtime: that is, a function pointer is loaded from the trait object vtable and invoked indirectly."
@bors: r+ rollup |
📌 Commit 58f0d72 has been approved by |
I sure hope this fix is right cc @steveklabnik
I sure hope this fix is right
cc @steveklabnik