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

Fix #3761 false about C #3766

Closed
wants to merge 1 commit into from
Closed

Conversation

maxmosk
Copy link

@maxmosk maxmosk commented Nov 1, 2023

There are not any methods in C

There are not any methods in C
@tolik518
Copy link

tolik518 commented Nov 4, 2023

While true, you can use the -> modifier in C to access members in a struct on a pointer.
The arrow is just syntactic sugar. You could always write (*struct).member instead of struct->member

@maxmosk
Copy link
Author

maxmosk commented Nov 4, 2023

While true, you can use the -> modifier in C to access members in a struct on a pointer. The arrow is just syntactic sugar. You could always write (*struct).member instead of struct->member

Yes, but you can't call method in C anyway. Maybe better to rewrite all about ->?

@tolik518
Copy link

tolik518 commented Nov 4, 2023

Yes, but you can't call method in C anyway. Maybe better to rewrite all about ->?

Yeah, I completely agree - talking about methods while mentioning C is wrong.
I think C should be mentioned in the paragraph though and it should be rewritten imo.

@chriskrycho
Copy link
Contributor

While it is technically true that C does not have methods, you can absolutely store a function pointer on a struct in C and then call it using -> access. (There is a reason for C++’s use of that exact syntax. 😉) Closing this as the point here is not pedantic precision about C and C++ but rather getting the point across about how Rust differs from them. Thanks, though!

@chriskrycho chriskrycho closed this Apr 3, 2024
@tolik518
Copy link

tolik518 commented Apr 3, 2024

@chriskrycho Calling functions methods is still wrong at that point though.

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.

3 participants