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

Update c++ interop reference page on lifetime handling interoperability #3798

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Emmankoko
Copy link
Contributor

@Emmankoko Emmankoko commented Apr 3, 2024

calling C++ constructors in D are now possible and so must be updated in documentation
@dkorpel

@dlang-bot
Copy link
Contributor

Thanks for your pull request and interest in making D better, @Emmankoko! We are looking forward to reviewing it, and you should be hearing from a maintainer soon.
Please verify that your PR follows this checklist:

  • My PR is fully covered with tests (you can see the coverage diff by visiting the details link of the codecov check)
  • My PR is as minimal as possible (smaller, focused PRs are easier to review than big ones)
  • I have provided a detailed rationale explaining my changes
  • New or modified functions have Ddoc comments (with Params: and Returns:)

Please see CONTRIBUTING.md for more information.


If you have addressed all reviews or aren't sure how to proceed, don't hesitate to ping us with a simple comment.

Bugzilla references

Your PR doesn't reference any Bugzilla issue.

If your PR contains non-trivial changes, please reference a Bugzilla issue or create a manual changelog.

@Emmankoko Emmankoko force-pushed the Lifetimefunc branch 3 times, most recently from bab50f7 to 9286c5f Compare April 4, 2024 13:32
@Emmankoko
Copy link
Contributor Author

Emmankoko commented Apr 4, 2024

Okay so I have finally been able to get this PR pass with the CI.
I'm sharing the preview of my changes here from CyberShadow.
After you have a look, we can discuss some of your changes you might suggest.
At the lifetime handling header

https://dtest.dlang.io/artifact/website-a787afecc4e6f5a767e58446ec396334c940e628-1441f51d92dcf19ade5fe29608bbed4d/web/spec/cpp_interface.html

@dkorpel

Copy link
Contributor

@ntrel ntrel left a comment

Choose a reason for hiding this comment

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

Thanks for working on this. Just to bear in mind, please try to avoid using 'you' in the spec.

Comment on lines 990 to 991
$(P Note that you cannot call C++ Copy constructor using D classes since classes in D are reference types.
you need value semantics to be able to copy so you need to call them using D struct.)
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
$(P Note that you cannot call C++ Copy constructor using D classes since classes in D are reference types.
you need value semantics to be able to copy so you need to call them using D struct.)
$(P Note that the C++ Copy constructor cannot be called using D classes since classes in D are reference types.
Value semantics are needed to be able to copy, so use a D struct.)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think that's better. Thanks for the correction!

Comment on lines 1052 to 1053
$(P Notice you don't need to call destroy on a struct object to invoke the destructor
since it does stack allocation and its lifetimes ends after leaving the stack.)
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
$(P Notice you don't need to call destroy on a struct object to invoke the destructor
since it does stack allocation and its lifetimes ends after leaving the stack.)
$(P Notice there is no need to call destroy on a struct object to invoke the destructor
since it does stack allocation (by default) and its lifetime ends with its declaration scope.)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Just force pushed the changes! Thanks again for the suggestions.

Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks!

calling C++ constructors in D are now possible and so must be updated in documentation
Copy link
Contributor

@dkorpel dkorpel left a comment

Choose a reason for hiding this comment

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

Thanks for writing this!
I don't use C++ so I can't verify the info deeply, perhaps @Geod24 can take a quick look?

@Emmankoko
Copy link
Contributor Author

Thanks for writing this!
I don't use C++ so I can't verify the info deeply, perhaps @Geod24 can take a quick look?

Okay let me ping him

@Geod24
Copy link
Member

Geod24 commented Sep 18, 2024

CC @TurkeyMan

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.

5 participants