-
Notifications
You must be signed in to change notification settings - Fork 963
Remove the content of the contrast between inline functions and macros #4823
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
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
91298f2
Remove the content of the contrast between inline functions and macros
Mq-b 93025d3
Delete irrelevant changes
Mq-b d89ccce
Keep the valuable content of the 'Inline functions vs. macros' paragr…
Mq-b 994d366
Merge branch 'Inline-functions-vs-macros' of https://github.com/Mq-b/…
Mq-b 1783fc0
Delete irrelevant changes
Mq-b 4b2340d
Update inline-functions-cpp.md
TylerMSFT 9d3f5d3
Merge branch 'main' into Inline-functions-vs-macros
TylerMSFT 14ca930
Update inline-functions-cpp.md
TylerMSFT f9fee1a
Update inline-functions-cpp.md
TylerMSFT File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 we should keep this paragraph.
It seems to me that only "Inline functions are similar to macros" needs to be improved. They are very different to me.
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 we should also include the fact that inline substitution is not mandatory, it occurs at the compiler's discretion, in the list. Currently the wording is confusing.
Inline functions are similar to macros, because the function code is expanded at the point of the call at compile time.
sounds like the substitution always happens.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.
@codeworm96 Your idea is also my idea.
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 agree. The statement is not that rigorous, and this causal relationship is also kind of far-fetched.
Uh oh!
There was an error while loading. Please reload this page.
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.
@frederick-vs-ja
I think we can just delete this paragraph and keep the last one:
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.
Replace this paragraph with:
Inline functions vs. macros
inline functions are parsed by the compiler, and macros are expanded by the preprocessor.
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.
The original wasn't good, and I'm not sure this is an improvement. 'Parsed by the compiler', although technically true, only indirectly conveys useful information. The crux of the matter that we are trying to get at is that the compiler, at its discretion, actually compiles the function and drops the code of the body into your code without the overhead of a function call, and with the benefit of actually going through the compiler so that language syntax and semantics are properly observed.
I see what the original author was trying to do here, but I think orienting the discussion about what an inline function is by comparing them with macros hurts more than it helps. I'll take a whack at redoing this section and we can see if it's an improvement.