Skip to content
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

reference: vtable entries are resolved at runtime #31677

Merged
merged 2 commits into from
Feb 25, 2016
Merged

reference: vtable entries are resolved at runtime #31677

merged 2 commits into from
Feb 25, 2016

Conversation

ivan
Copy link
Contributor

@ivan ivan commented Feb 15, 2016

I sure hope this fix is right

cc @steveklabnik

@jonas-schievink
Copy link
Contributor

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.

@steveklabnik
Copy link
Member

/cc @nikomatsakis @aturon what is the best wording here?

@aturon
Copy link
Member

aturon commented Feb 16, 2016

I agree with @jonas-schievink. It'd be mildly more clear as

a method on a trait object is resolved only to a vtable entry at compile time

instead of:

a method on a trait object is only resolved to a vtable entry at compile time

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.
Copy link
Contributor

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."

@ivan
Copy link
Contributor Author

ivan commented Feb 18, 2016

r? @steveklabnik

@steveklabnik
Copy link
Member

@bors: r+ rollup

@bors
Copy link
Contributor

bors commented Feb 22, 2016

📌 Commit 58f0d72 has been approved by steveklabnik

Manishearth added a commit to Manishearth/rust that referenced this pull request Feb 24, 2016
bors added a commit that referenced this pull request Feb 24, 2016
@bors bors merged commit 58f0d72 into rust-lang:master Feb 25, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants