Skip to content

Add D string overloads to methods in StringTable#8547

Merged
dlang-bot merged 1 commit intodlang:masterfrom
jacob-carlborg:dstring_overlods
Aug 10, 2018
Merged

Add D string overloads to methods in StringTable#8547
dlang-bot merged 1 commit intodlang:masterfrom
jacob-carlborg:dstring_overlods

Conversation

@jacob-carlborg
Copy link
Contributor

This will help reduce the surface of where C strings and pointer length pairs are used.

@dlang-bot
Copy link
Contributor

Thanks for your pull request and interest in making D better, @jacob-carlborg! 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 annotated coverage diff directly on GitHub with CodeCov's browser extension
  • 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 fetch digger
dub run digger -- build "master + dmd#8547"

return getValue(table[i].vptr);
}

inout(StringValue)* lookup(const(char)[] str) inout nothrow pure
Copy link
Contributor

Choose a reason for hiding this comment

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

I hate to nitpick, but new public functions should have full DDoc.

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 know, I know 😃.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

*
* Returns: the string's associated value, or `null` if the string doesn't
* exist in the string table
*/
Copy link
Contributor

Choose a reason for hiding this comment

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

FWIW the DStyle we use for new symbols at Druntime/Phobos says:

Documentation comments should not have leading stars on each line.

https://dlang.org/dstyle.html#phobos_documentation

Copy link
Contributor Author

Choose a reason for hiding this comment

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

😞

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It looks so weird. I have a feeling that most of the code out there is not using this style.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed.


Params:
s = the string to look up
length = the length of $(D_PARAM s)
Copy link
Contributor

Choose a reason for hiding this comment

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

Technically str would need to be documented too (as it gets dittoed into this documentation.)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We need a better way to inherit documentation that ditto. Fixed.

This will help reduce the surface of where C strings and pointer
length pairs are used.
@jacob-carlborg
Copy link
Contributor Author

jacob-carlborg commented Aug 9, 2018

Do these new methods need to be placed at after all the C++ methods sine they cannot appear in the C++ header?

@jacob-carlborg
Copy link
Contributor Author

@JinShil @wilzbach ping.

@JinShil
Copy link
Contributor

JinShil commented Aug 9, 2018

Do these new methods need to be placed at after all the C++ methods sine they cannot appear in the C++ header?

Yeah, that may be nice. I won't hold up this PR on it though, and it can always be done as a followup.

@JinShil
Copy link
Contributor

JinShil commented Aug 9, 2018

Semaphore CI seems stuck, so I'm closing and re-opening.

@JinShil JinShil closed this Aug 9, 2018
@JinShil JinShil reopened this Aug 9, 2018
@dlang-bot dlang-bot merged commit 393f470 into dlang:master Aug 10, 2018
@jacob-carlborg jacob-carlborg deleted the dstring_overlods branch August 10, 2018 07:30
@jacob-carlborg
Copy link
Contributor Author

Do these new methods need to be placed at after all the C++ methods sine they cannot appear in the C++ header?

Yeah, that may be nice

Actually, since these functions are not virtual and don't occupy a slot in the vtable the order doesn't matter [1]. In that case I think it makes more sense to have the overloads next to each other.

[1] #8550 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants