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

feat: add pointers concept #823

Merged
merged 4 commits into from
Oct 1, 2024
Merged

feat: add pointers concept #823

merged 4 commits into from
Oct 1, 2024

Conversation

vaeng
Copy link
Contributor

@vaeng vaeng commented Mar 1, 2024

I would put that concept after "references" and follow up with smart pointers. the trinity of confusion.

I think windowing system might be a fitting concept exercise.

Copy link
Contributor Author

@vaeng vaeng left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pointers. Haiyaa.
It is difficult to make it short and interesting but not shallow.
Any suggestions?

@vaeng vaeng added x:action/proofread Proofread text x:module/concept Work on Concepts x:type/docs Work on Documentation x:rep/large Large amount of reputation labels Mar 1, 2024
Copy link
Contributor

@siebenschlaefer siebenschlaefer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not bad!

This whole documents describes pointers as "memory addresses". That is not wrong, at least on a practical level.

Formally (I think) neither the C++17 standard nor the C11 standard (which is part of the C++17 standard) define pointers in terms of "memory" but rather with "addresses" and "objects". Instead of defining what a pointer is they describe how you can derive it, when it is valid, how you can use it.
You could consider replacing many occurrences of "memory" in this PR with "objects", e.g. instead of "Pointers are a way to share memory" you could write "Pointers are a way to share objects". That would match the official terminology.

If you want to describe pointers as addresses in memory that's fine with me, just keep in mind that this is not in the official specification, and you cannot refer to some formal definition but have to describe it in your own words.

I'm missing a warning in the section about dynamic memory allocation that modern C++ code should use smart pointers (perhaps with a link to the other concept). I'd rather remove that whole section and put it into a different concept about dynamic memory allocation.

concepts/pointers/.meta/config.json Outdated Show resolved Hide resolved
concepts/pointers/introduction.md Outdated Show resolved Hide resolved
concepts/pointers/introduction.md Outdated Show resolved Hide resolved
concepts/pointers/introduction.md Outdated Show resolved Hide resolved
concepts/pointers/introduction.md Outdated Show resolved Hide resolved
concepts/pointers/introduction.md Outdated Show resolved Hide resolved
concepts/pointers/introduction.md Show resolved Hide resolved
concepts/pointers/introduction.md Show resolved Hide resolved
concepts/pointers/introduction.md Outdated Show resolved Hide resolved
@vaeng
Copy link
Contributor Author

vaeng commented Mar 4, 2024

@siebenschlaefer, if you think this is good to merge now, I will add the about.md file and make configlet happy.

Copy link
Contributor

@siebenschlaefer siebenschlaefer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good.

My new suggestions are mostly nitpicks, feel free to ignore or disregard them.

concepts/pointers/introduction.md Show resolved Hide resolved
concepts/pointers/introduction.md Show resolved Hide resolved
concepts/pointers/introduction.md Outdated Show resolved Hide resolved
concepts/pointers/introduction.md Outdated Show resolved Hide resolved
@vaeng
Copy link
Contributor Author

vaeng commented Oct 1, 2024

I moved the section about dynamic memory allocation to the about.md and marked it as advanced.

@vaeng vaeng merged commit 46f93c0 into main Oct 1, 2024
7 checks passed
@vaeng vaeng deleted the feat--add-pointers-concept branch October 1, 2024 12:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
x:action/proofread Proofread text x:module/concept Work on Concepts x:rep/large Large amount of reputation x:type/docs Work on Documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants