Skip to content

dtoh: Emit _d_dynamicArray template which represents slices - #11882

Merged
dlang-bot merged 2 commits into
dlang:masterfrom
MoonlightSentinel:dtoh-array
Oct 26, 2020
Merged

dlang-bot merged 2 commits into
dlang:masterfrom
MoonlightSentinel:dtoh-array

Conversation

@MoonlightSentinel

@MoonlightSentinel MoonlightSentinel commented Oct 18, 2020 •

Copy link
Copy Markdown
Contributor

Since slices are a central building block of D, they should also be easily accessible from C++.

CC @ibuclaw


Questions:

  • Should _d_dynamicArray define addtional functions, e.g. operator[]?
  • Should _d_dynamicArray be hidden behind an #if !defined(...) to allow custom definitions?

@dlang-bot

Copy link
Copy Markdown

Thanks for your pull request and interest in making D better, @MoonlightSentinel! 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.

Testing this PR locally

If you don't have a local development environment setup, you can use Digger to test this PR:

dub run digger -- build "master + dmd#11882"

@thewilsonator

Copy link
Copy Markdown
Contributor

See also https://github.com/thewilsonator/interop/blob/master/c%2B%2B/dslice.h

@jacob-carlborg which were the PRs we tried to add this in?

@ibuclaw

ibuclaw commented Oct 18, 2020

Copy link
Copy Markdown
Member

See also https://github.com/thewilsonator/interop/blob/master/c%2B%2B/dslice.h

@jacob-carlborg which were the PRs we tried to add this in?

That would have been my next thought. I know we use DArray and DString internally within dmd. But maybe something like _d_dynamicArray would be a bit less generic and stick out more.

@jacob-carlborg

Copy link
Copy Markdown
Contributor

#8120

@ibuclaw

ibuclaw commented Oct 18, 2020

Copy link
Copy Markdown
Member

#8120

To make it clear, dtoh only deals with fields, not parameters.

@MoonlightSentinel

Copy link
Copy Markdown
Contributor Author

That would have been my next thought. I know we use DArray and DString internally within dmd. But maybe something like _d_dynamicArray would be a bit less generic and stick out more.

Fine by me

@MoonlightSentinel

Copy link
Copy Markdown
Contributor Author

Made a few adjustments:

  • use _d_dynamicArray instead of DArray
  • allow custom implementations by defining CUSTOM_D_ARRAY_TYPE
  • add operator[] with bound checks (up for debate).

@MoonlightSentinel MoonlightSentinel changed the title dtoh: Emit DArray template which represents slices dtoh: Emit _d_dynamicArray template which represents slices Oct 18, 2020
@MoonlightSentinel
MoonlightSentinel force-pushed the dtoh-array branch 3 times, most recently from 77e39de to c200b5d Compare October 23, 2020 09:56
Since slices are a central building block of D, they should also be
easily accessible from C++.
... s.t. it can be used like a normal array (+ bounds checking)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants