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

Deep Dive: dyn Trait Objects and Vtables in Rust #46

Open
geo-ant opened this issue Mar 15, 2023 · 7 comments
Open

Deep Dive: dyn Trait Objects and Vtables in Rust #46

geo-ant opened this issue Mar 15, 2023 · 7 comments

Comments

@geo-ant
Copy link
Owner

geo-ant commented Mar 15, 2023

comments for the article go here

@zeenix
Copy link

zeenix commented Mar 25, 2023

Great post!

I think the "former" and "latter" are inverted in the paragraph about pointers and fat pointers? 🤔

from from the pointer types Box, &dyn Trait, and &mut dyn Trait. While the former are really just pointers 8, the latter are also fat pointers.

Also I not noticed a typo: extra "from".

@geo-ant
Copy link
Owner Author

geo-ant commented Mar 25, 2023

Thank you kindly @zeenix. I removed the duplicate from. I'm not a native speaker and I looked up the former / latter thingy again and I believe I used it correctly. If you think the phrasing is unclear, I'll try and come up with something better.

@zeenix
Copy link

zeenix commented Mar 25, 2023

You got it! I think the confusing bit (for me at least) was that Box isn't a pointer. Maybe it's just my C background overshadowing my Rust knowledge but I think only references can be called pointers. 🤔

@zeenix
Copy link

zeenix commented Mar 25, 2023

In any case this small correction will make things clearer: "former are" -> "former is".

@geo-ant
Copy link
Owner Author

geo-ant commented Mar 26, 2023

You got it! I think the confusing bit (for me at least) was that Box isn't a pointer. Maybe it's just my C background overshadowing my Rust knowledge but I think only references can be called pointers. 🤔

Hey, I'll think of a way to rephrase that parapraph, I think it's confusing after all.

One more thing though. And I am honestly not trying to argue with you, just trying to understand your point and I really appreciate that you took the time to comment. Why do you not consider Box a pointer? The rust doc calls it a pointer type. Is it because it contains more members than just the raw pointer (i.e. the allocator)?

@zeenix
Copy link

zeenix commented Mar 26, 2023

One more thing though. And I am honestly not trying to argue with you, just trying to understand your point and I really appreciate that you took the time to comment.

Don't worry about it. It'd be perfectly fine to argue. :) I try not to take things personally. We're all just learners here w/ different way of looking at things.

Why do you not consider Box a pointer? The rust doc calls it a pointer type. Is it because it contains more members than just the raw pointer (i.e. the allocator)?

No. I guess it boils down to the fact that I think there is a difference between pointer type and pointer. I'd consider Box (as well as Arc, Rc, Cell etc) pointer types but not pointers. E.g here:

struct Str<'a> {
    pointer: &'a str,
}

I'd call Str a pointer type but not a pointer, while I'd call Str::pointer a pointer. I hope that clarifies things. 👍

@geo-ant
Copy link
Owner Author

geo-ant commented Mar 27, 2023

I understand and that makes sense. I'll try to rephrase the paragraph, but I still have to consolidate how I think about these things. Thanks for taking the time to discuss this. I hope the Rust community will stay as welcoming and positive even as it grows more :)

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

No branches or pull requests

2 participants